/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2005
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.ui.rich.full.dialogs;

import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.ListIterator;
import java.util.Locale;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

import br.ufmg.dees.insane.commons.dialogs.DecimalField;
import br.ufmg.dees.insane.commons.dialogs.TabbedDialog;
import br.ufmg.dees.insane.crossSection.CrossSection;
import br.ufmg.dees.insane.materialMedia.material.LinearElasticIsotropic;
import br.ufmg.dees.insane.materialMedia.material.Material;
import br.ufmg.dees.insane.model.disc.analysismodel.AxiSymetricAnalysisM;
import br.ufmg.dees.insane.model.disc.analysismodel.PlaneStrainAnalysisM;
import br.ufmg.dees.insane.model.disc.analysismodel.PlaneStressAnalysisM;
import br.ufmg.dees.insane.model.disc.element.FrameElement;
import br.ufmg.dees.insane.model.disc.element.force.ElementForce;
import br.ufmg.dees.insane.model.disc.fem.FemModel;
import br.ufmg.dees.insane.model.disc.pointforce.PointForce;
import br.ufmg.dees.insane.ui.rich.full.InsaneInternalInterface;

/**
 * A class representing creation dialog on screen.
 * For example:
 * <pre>
 *    ElmAttributesDialog dgl = new ElmAttributesDialog(parent);
 *    dgl.pack();
 * </pre>
 *
 * @author Fonseca, Flavio & Pitangueira, Roque
 * @see gui.InsaneInternalInterface
 * @since March 2004
 */
public final class ElmAttributesDialog extends TabbedDialog {
	
	/**
	 * Comment for <code>serialVersionUID</code>
	 */
	private static final long serialVersionUID = 1L;
	private InsaneInternalInterface parent;
	private NumberFormat numberFormat;
	private NumberFormat numberFormat2;
	private CardLayout concCardManager = new CardLayout();
	private CardLayout distCardManager = new CardLayout();
	private FemModel fmodel;
	
	private String anlType;
	
	private String[] analysisTypeStr;
	private JComboBox analysisTypeCombo;
	public String anlTypeChosen;
	
	private JPanel matButPane = new JPanel();
	private String[] matLabelList;
	private JComboBox matListCombo = new JComboBox();
	private DecimalField matEField;
	private DecimalField matGField;
	private DecimalField matPoissonField;
	private DecimalField matThermalField;
	public String matLabel;
	
	private JPanel secButPane = new JPanel();
	private String[] secLabelList;
	private JComboBox secListCombo = new JComboBox();
	private DecimalField secIxField;
	private DecimalField secIyField;
	private DecimalField secIzField;
	private DecimalField secAField;
	private DecimalField secHField;
	private DecimalField secThickField;
	public String secLabel;
	
	private JPanel distButPane = new JPanel();
	private boolean distNewPressed = false;
	private String[] distLabelList;
	private JComboBox distListCombo = new JComboBox();
	private JButton distNewButton = new JButton();
	private JButton distModButton = new JButton();
	private JButton distOkButton = new JButton();
	private JButton distCancButton = new JButton();
	private JTextField distLabelField = new JTextField();
	private DecimalField distAField;
	private DecimalField distBField;
	private DecimalField distFx1Field;
	private DecimalField distFy1Field;
	private DecimalField distFz1Field;
	private DecimalField distMx1Field;
	private DecimalField distFx2Field;
	private DecimalField distFy2Field;
	private DecimalField distFz2Field;
	private DecimalField distMx2Field;
	public ArrayList<ElementForce> distForces = new ArrayList<ElementForce>();
	
	private JPanel concButPane = new JPanel();
	private boolean concNewPressed = false;
	private String[] concLabelList;
	private JComboBox concListCombo = new JComboBox();
	private JButton concNewButton = new JButton();
	private JButton concModButton = new JButton();
	private JButton concOkButton = new JButton();
	private JButton concCancButton = new JButton();
	private JTextField concLabelField = new JTextField();
	private JLabel concLLabel = new JLabel();
	private DecimalField concAField;
	private DecimalField concFxField;
	private DecimalField concFyField;
	private DecimalField concFzField;
	private DecimalField concMxField;
	private DecimalField concMyField;
	private DecimalField concMzField;
	public ArrayList<PointForce> concForces = new ArrayList<PointForce>();
	
	private DecimalField TsField;
	private DecimalField TnField;
	private DecimalField TiField;
	public double Ts;
	public double Tn;
	public double Ti;
	
	private DecimalField eqFx1Field;
	private DecimalField eqFy1Field;
	private DecimalField eqFz1Field;
	private DecimalField eqMx1Field;
	private DecimalField eqMy1Field;
	private DecimalField eqMz1Field;
	private DecimalField eqFx2Field;
	private DecimalField eqFy2Field;
	private DecimalField eqFz2Field;
	private DecimalField eqMx2Field;
	private DecimalField eqMy2Field;
	private DecimalField eqMz2Field;
	public double eqFx1;
	public double eqFy1;
	public double eqFz1;
	public double eqMx1;
	public double eqMy1;
	public double eqMz1;
	public double eqFx2;
	public double eqFy2;
	public double eqFz2;
	public double eqMx2;
	public double eqMy2;
	public double eqMz2;
	
	private DecimalField psDx1Field;
	private DecimalField psDy1Field;
	private DecimalField psDz1Field;
	private DecimalField psRx1Field;
	private DecimalField psRy1Field;
	private DecimalField psRz1Field;
	private DecimalField psDx2Field;
	private DecimalField psDy2Field;
	private DecimalField psDz2Field;
	private DecimalField psRx2Field;
	private DecimalField psRy2Field;
	private DecimalField psRz2Field;
	public double psDx1;
	public double psDy1;
	public double psDz1;
	public double psRx1;
	public double psRy1;
	public double psRz1;
	public double psDx2;
	public double psDy2;
	public double psDz2;
	public double psRx2;
	public double psRy2;
	public double psRz2;
	
	private JCheckBox liberationLdx1 = new JCheckBox("");
	private JCheckBox liberationLdy1 = new JCheckBox("");
	private JCheckBox liberationLdz1 = new JCheckBox("");
	private JCheckBox liberationLrx1 = new JCheckBox("");
	private JCheckBox liberationLry1 = new JCheckBox("");
	private JCheckBox liberationLrz1 = new JCheckBox("");
	private JCheckBox liberationLdx2 = new JCheckBox("");
	private JCheckBox liberationLdy2 = new JCheckBox("");
	private JCheckBox liberationLdz2 = new JCheckBox("");
	private JCheckBox liberationLrx2 = new JCheckBox("");
	private JCheckBox liberationLry2 = new JCheckBox("");
	private JCheckBox liberationLrz2 = new JCheckBox("");
	public boolean Ldx1;
	public boolean Ldy1;
	public boolean Ldz1;
	public boolean Lrx1;
	public boolean Lry1;
	public boolean Lrz1;
	public boolean Ldx2;
	public boolean Ldy2;
	public boolean Ldz2;
	public boolean Lrx2;
	public boolean Lry2;
	public boolean Lrz2;
	
	public double K1dx;
	public double K1dy;
	public double K1dz;
	public double K1rx;
	public double K1ry;
	public double K1rz;
	public double K2dx;
	public double K2dy;
	public double K2dz;
	public double K2rx;
	public double K2ry;
	public double K2rz;
	
	public boolean modified = false;
	
//*****************************************************************************
	
	/**
	 * Constructor method, calling super with the especific title.
	 *
	 * @param parent The parent of the class.
	 * @see gui.InsaneInternalInterface
	 */
	public ElmAttributesDialog(InsaneInternalInterface parent) {
		this.parent = parent;
		fmodel = parent.getModel().getDiscreteModel();
		
		concNewButton.setText(parent.getResourceBundle().getString("gNewButton"));
		concModButton.setText(parent.getResourceBundle().getString("gModifyButton"));
		concOkButton.setText(parent.getResourceBundle().getString("gOkButton"));
		concCancButton.setText(parent.getResourceBundle().getString("gCancelButton"));
		distNewButton.setText(parent.getResourceBundle().getString("gNewButton"));
		distModButton.setText(parent.getResourceBundle().getString("gModifyButton"));
		distOkButton.setText(parent.getResourceBundle().getString("gOkButton"));
		distCancButton.setText(parent.getResourceBundle().getString("gCancelButton"));
		
		if (this.parent.getController().getSelection().size() != 1 )
			anlType = fmodel.getGlobalAnalysisModel().getType();
		else {
			FrameElement elm = (FrameElement)this.parent.getController().getSelection().get(0);
			anlType = elm.getAnalysisModel().getType();
		}
		
		if (!(fmodel.getGlobalAnalysisModel().getType().equals("Grid"))) {
			analysisTypeStr = new String[3];
			analysisTypeStr[0] = parent.getResourceBundle().getString("dGAnlDialog01");
			analysisTypeStr[1] = parent.getResourceBundle().getString("dGAnlDialog02");
			analysisTypeStr[2] = parent.getResourceBundle().getString("dGAnlDialog03");
		} else {
			analysisTypeStr = new String[1];
			analysisTypeStr[0] = parent.getResourceBundle().getString("dGAnlDialog04");
		}
		if((fmodel.getGlobalAnalysisModel() instanceof PlaneStrainAnalysisM)|| 
		   (fmodel.getGlobalAnalysisModel() instanceof PlaneStressAnalysisM)||
		   (fmodel.getGlobalAnalysisModel() instanceof AxiSymetricAnalysisM)){
			analysisTypeStr = new String[4];
			analysisTypeStr[0] = parent.getResourceBundle().getString("dGAnlDialog07");
			analysisTypeStr[1] = parent.getResourceBundle().getString("dGAnlDialog08");
			analysisTypeStr[2] = parent.getResourceBundle().getString("dGAnlDialog09");
			analysisTypeStr[3] = parent.getResourceBundle().getString("dGAnlDialog03");
		}
		analysisTypeCombo = new JComboBox(analysisTypeStr);
		
		setUpMaterialsList();
		setUpMaterialsCombo();
		setUpSectionsList();
		setUpSectionsCombo();
		
		setUpFormat();
		setUpFields();
		
		setUpConcList();
		setUpConcCombo();
		setUpDistList();
		setUpDistCombo();
		
		//Sets up the general panel
		JPanel generalPane = new JPanel();
		generalPane.setPreferredSize(new Dimension(360,300));
		generalPane.setLayout(new BoxLayout(generalPane, BoxLayout.Y_AXIS));
		
		//Setting subpanel analysis model
		JPanel anlPane = new JPanel();
        anlPane.setMaximumSize(new Dimension(500,50));
		anlPane.setBorder(BorderFactory.createCompoundBorder(
			BorderFactory.createTitledBorder(parent.getResourceBundle().getString("dElmAttDialog03")),
			BorderFactory.createEmptyBorder(2,2,2,2)));
		analysisTypeCombo.addItemListener(new AnlComboListener());
		analysisTypeCombo.setMaximumSize(new Dimension(300,26));
		analysisTypeCombo.setPreferredSize(new Dimension(300,26));
		analysisTypeCombo.setMinimumSize(new Dimension(300,26));
		analysisTypeCombo.setSize(new Dimension(300,26));
		anlPane.add(analysisTypeCombo);
		
		//Setting subpanel material
		JPanel materialPane = new JPanel();
		materialPane.setLayout(new BoxLayout(materialPane, BoxLayout.Y_AXIS));
        materialPane.setMaximumSize(new Dimension(500,155));
		materialPane.setBorder(BorderFactory.createCompoundBorder(
			BorderFactory.createTitledBorder(parent.getResourceBundle().getString("dMatDialog01")),
			BorderFactory.createEmptyBorder(2,2,2,2)));
		
		matListCombo.setMaximumSize(new Dimension(300,26));
		matListCombo.setPreferredSize(new Dimension(300,26));
		matListCombo.setMinimumSize(new Dimension(300,26));
		matListCombo.setSize(new Dimension(300,26));
		
		matListCombo.setMaximumRowCount(5);
		
		matListCombo.addItemListener(new MatComboListener());
		matGField.addFocusListener(new MatGListener());
		matPoissonField.addFocusListener(new MatPoissonListener());
		matThermalField.addFocusListener(new TempListener());
		
		matEField.setEditable(false);
		matGField.setEditable(false);
		matPoissonField.setEditable(false);
		matThermalField.setEditable(false);
		
		matButPane.add(matListCombo);
		
		JPanel matPropPane = new JPanel();
		matPropPane.setLayout(new GridLayout(2,2,2,2));
		
		JPanel matEPane = new JPanel();
		JPanel matGPane = new JPanel();
		JPanel matPoissonPane = new JPanel();
		JPanel matThermalPane = new JPanel();
		
		matEPane.add(new JLabel("E:"));
		matEPane.add(matEField);
		matGPane.add(new JLabel("G:"));
		matGPane.add(matGField);
		matPoissonPane.add(new JLabel(" \u03BD:"));
		matPoissonPane.add(matPoissonField);
		matThermalPane.add(new JLabel("\u03B1:"));
		matThermalPane.add(matThermalField);
		matPropPane.add(matEPane);
		matPropPane.add(matGPane);
		matPropPane.add(matPoissonPane);
		matPropPane.add(matThermalPane);
		
		materialPane.add(matButPane);
		materialPane.add(matPropPane);
		
		//Setting subpanel cross section
		JPanel sectionPane = new JPanel();
		sectionPane.setLayout(new BoxLayout(sectionPane, BoxLayout.Y_AXIS));
        sectionPane.setMaximumSize(new Dimension(500,155));
		sectionPane.setBorder(BorderFactory.createCompoundBorder(
			BorderFactory.createTitledBorder(parent.getResourceBundle().getString("dCSDialog01")),
			BorderFactory.createEmptyBorder(2,2,2,2)));
		
		secListCombo.setMaximumSize(new Dimension(300,26));
		secListCombo.setPreferredSize(new Dimension(300,26));
		
		secListCombo.setMaximumRowCount(5);
		
		secIxField.setEditable(false);
		secIyField.setEditable(false);
		secIzField.setEditable(false);
		secAField.setEditable(false);
		secHField.setEditable(false);
		secThickField.setEditable(false);
		
		secListCombo.addItemListener(new SecComboListener());
		secHField.addFocusListener(new TempListener());
		
		secButPane.add(secListCombo);
		
		JPanel secPropPane = new JPanel();
		secPropPane.setLayout(new GridLayout(3,1,0,0));
		
		JPanel secPropSPane = new JPanel();
		secPropSPane.setLayout(new GridLayout(1,3,2,2));
		JPanel secPropMPane = new JPanel();
		secPropMPane.setLayout(new GridLayout(1,2,2,2));
		JPanel secPropIPane = new JPanel();
		secPropIPane.setLayout(new GridLayout(1,1,2,2));
		
		JPanel secIxPane = new JPanel();
		JPanel secIyPane = new JPanel();
		JPanel secIzPane = new JPanel();
		JPanel secAPane = new JPanel();
		JPanel secHPane = new JPanel();
		JPanel secThickPane = new JPanel();
		
		secIxPane.add(new JLabel("Ix:"));
		secIxPane.add(secIxField);
		secIyPane.add(new JLabel("Iy:"));
		secIyPane.add(secIyField);
		secIzPane.add(new JLabel("Iz:"));
		secIzPane.add(secIzField);
		secAPane.add(new JLabel(parent.getResourceBundle().getString("dCSDialog02")));
		secAPane.add(secAField);
		secHPane.add(new JLabel(parent.getResourceBundle().getString("dCSDialog03")));
		secHPane.add(secHField);
		secThickPane.add(new JLabel(parent.getResourceBundle().getString("dCSDialog11")));
		secThickPane.add(secThickField);
		
		secPropSPane.add(secIxPane);
		secPropSPane.add(secIyPane);
		secPropSPane.add(secIzPane);
		secPropMPane.add(secAPane);
		secPropMPane.add(secHPane);
		secPropIPane.add(secThickPane);
		
		secPropPane.add(secPropSPane);
		secPropPane.add(secPropMPane);
		secPropPane.add(secPropIPane);
		
		sectionPane.add(secButPane);
		sectionPane.add(secPropPane);
		
		//This panel is a dumb way of correcting the general panel's layout
//		JPanel emptyPanel = new JPanel();
//		emptyPanel.setMinimumSize(new Dimension(300, 20));
		
		generalPane.add(anlPane);
		generalPane.add(materialPane);
		generalPane.add(sectionPane);
//		generalPane.add(emptyPanel);
		
		//Sets up the concentrated forces panel
		concListCombo = new JComboBox(concLabelList);
		
		JPanel concForcesPane = new JPanel();
		concForcesPane.setPreferredSize(new Dimension(360,280));
		concForcesPane.setLayout(new BoxLayout(concForcesPane, BoxLayout.Y_AXIS));
		
		concLabelField.setMaximumSize(new Dimension(100,26));
		concListCombo.setMaximumSize(new Dimension(100,26));
		concNewButton.setMaximumSize(new Dimension(100,26));
		concModButton.setMaximumSize(new Dimension(100,26));
		concOkButton.setMaximumSize(new Dimension(100,26));
		concCancButton.setMaximumSize(new Dimension(100,26));
		
		concLabelField.setPreferredSize(new Dimension(100,26));
		concListCombo.setPreferredSize(new Dimension(100,26));
		concNewButton.setPreferredSize(new Dimension(100,26));
		concModButton.setPreferredSize(new Dimension(100,26));
		concOkButton.setPreferredSize(new Dimension(100,26));
		concCancButton.setPreferredSize(new Dimension(100,26));
		
		concListCombo.setMaximumRowCount(5);
		
		concListCombo.addItemListener(new ConcComboListener());
		concNewButton.addActionListener(new ConcNewListener());
		concModButton.addActionListener(new ConcModListener());
		concOkButton.addActionListener(new ConcOkListener());
		concCancButton.addActionListener(new ConcCancListener());
		
		concLabelField.setEditable(false);
		concAField.setEditable(false);
		concFxField.setEditable(false);
		concFyField.setEditable(false);
		concFzField.setEditable(false);
		concMxField.setEditable(false);
		concMyField.setEditable(false);
		concMzField.setEditable(false);
		
		String imgName = "br/ufmg/dees/insane/images/";
		imgName += parent.getResourceBundle().getString("imgConcForces100");
		
		JPanel concPicPanel = new JPanel();
		concPicPanel.setMaximumSize(new Dimension(500,100));
		concPicPanel.add(new JLabel( new ImageIcon(ClassLoader.getSystemResource(imgName)) ));
		concForcesPane.add(concPicPanel);
		
		concButPane.setLayout(concCardManager);
			
		JPanel concBut1Pane = new JPanel();
		concBut1Pane.setLayout(new GridLayout(1,2,2,2));
        concBut1Pane.setMaximumSize(new Dimension(500,120));
		JPanel concBut1aPane = new JPanel();
		concBut1aPane.setLayout(new GridLayout(1,2,2,2));
		concBut1aPane.add(concNewButton);
		concBut1aPane.add(concModButton);
		concBut1Pane.add(concListCombo);
		concBut1Pane.add(concBut1aPane);
		
		JPanel concBut2Pane = new JPanel();
		concBut2Pane.setLayout(new GridLayout(1,2,2,2));
        concBut2Pane.setMaximumSize(new Dimension(500,120));
		concBut2Pane.add(concLabelField);
		JPanel concBut2aPane = new JPanel();
		concBut2aPane.setLayout(new GridLayout(1,2,2,2));
		concBut2aPane.add(concOkButton);
		concBut2aPane.add(concCancButton);
		concBut2Pane.add(concBut2aPane);
		
		concButPane.add(concBut1Pane, "concCombo");
		concButPane.add(concBut2Pane, "concLabel");
		
		concForcesPane.add(concButPane);
		
		JPanel concDistPane = new JPanel();
		concDistPane.setMaximumSize(new Dimension(500,80));
		concDistPane.setBorder(BorderFactory.createCompoundBorder(
			BorderFactory.createTitledBorder(parent.getResourceBundle().getString("dEConcForDialog01")),
			BorderFactory.createEmptyBorder(2,2,2,2)));
		GridBagLayout gridbag = new GridBagLayout();
		GridBagConstraints c = new GridBagConstraints();
		concDistPane.setLayout(gridbag);
		c.fill = GridBagConstraints.HORIZONTAL;
		JPanel concAPane = new JPanel();
		concAPane.add(new JLabel("A:"));
		concAPane.add(concAField);
		c.gridwidth = 1;
		c.gridx = 0;
		c.gridy = 0;
		c.anchor = GridBagConstraints.WEST;
		gridbag.setConstraints(concAPane, c);
		concDistPane.add(concAPane);
		JPanel concLPane = new JPanel();
		concLPane.add(concLLabel);
		c.gridwidth = 2;
		c.gridx = 1;
		c.gridy = 0;
		c.weightx = 1;
		c.anchor = GridBagConstraints.LINE_END;
		gridbag.setConstraints(concLPane, c);
		concDistPane.add(concLPane);
		concForcesPane.add(concDistPane);
		
		JPanel concValuesPane = new JPanel();
		concValuesPane.setLayout(new GridLayout(2,3,2,2));
        concValuesPane.setMaximumSize(new Dimension(500,300));
		concValuesPane.setBorder(BorderFactory.createCompoundBorder(
			BorderFactory.createTitledBorder(parent.getResourceBundle().getString("dEConcForDialog02")),
			BorderFactory.createEmptyBorder(2,2,2,2)));
		
		JPanel concFxPanel = new JPanel();
		concFxPanel.add(new JLabel("Fx:"));
		concFxPanel.add(concFxField);
		concValuesPane.add(concFxPanel);
		
		JPanel concFyPanel = new JPanel();
		concFyPanel.add(new JLabel("Fy:"));
		concFyPanel.add(concFyField);
		concValuesPane.add(concFyPanel);
		
		JPanel concFzPanel = new JPanel();
		concFzPanel.add(new JLabel("Fz:"));
		concFzPanel.add(concFzField);
		concValuesPane.add(concFzPanel);
		
		JPanel concMxPanel = new JPanel();
		concMxPanel.add(new JLabel("Mx:"));
		concMxPanel.add(concMxField);
		concValuesPane.add(concMxPanel);
		
		JPanel concMyPanel = new JPanel();
		concMyPanel.add(new JLabel("My:"));
		concMyPanel.add(concMyField);
		concValuesPane.add(concMyPanel);
		
		JPanel concMzPanel = new JPanel();
		concMzPanel.add(new JLabel("Mz:"));
		concMzPanel.add(concMzField);
		concValuesPane.add(concMzPanel);
		
		concForcesPane.add(concValuesPane);
		
		//Perhaps it will be removed
		JPanel concEmptyPanel = new JPanel();
		concEmptyPanel.setMinimumSize(new Dimension(300, 50));
		concEmptyPanel.setMaximumSize(new Dimension(300, 50));
		concEmptyPanel.setPreferredSize(new Dimension(300, 50));
		concForcesPane.add(concEmptyPanel);
		
		//Sets up the distributed forces panel
		distListCombo = new JComboBox(distLabelList);
		
		JPanel distForcesPane = new JPanel();
		distForcesPane.setPreferredSize(new Dimension(360,350));
		distForcesPane.setLayout(new BoxLayout(distForcesPane, BoxLayout.Y_AXIS));
		
		distListCombo.setMaximumSize(new Dimension(100,26));
		distNewButton.setMaximumSize(new Dimension(100,26));
		distModButton.setMaximumSize(new Dimension(100,26));
		distOkButton.setMaximumSize(new Dimension(100,26));
		distCancButton.setMaximumSize(new Dimension(100,26));
		
		distListCombo.setMaximumRowCount(5);
		
		distListCombo.addItemListener(new DistComboListener());
		distNewButton.addActionListener(new DistNewListener());
		distModButton.addActionListener(new DistModListener());
		distOkButton.addActionListener(new DistOkListener());
		distCancButton.addActionListener(new DistCancListener());
		
		distLabelField.setEditable(false);
		distAField.setEditable(false);
		distBField.setEditable(false);
		distFx1Field.setEditable(false);
		distFy1Field.setEditable(false);
		distFz1Field.setEditable(false);
		distMx1Field.setEditable(false);
		distFx2Field.setEditable(false);
		distFy2Field.setEditable(false);
		distFz2Field.setEditable(false);
		distMx2Field.setEditable(false);
		
		imgName = "br/ufmg/dees/insane/images/" + parent.getResourceBundle().getString("imgDistForces100");
		
		JPanel distPicPanel = new JPanel();
		distPicPanel.setMaximumSize(new Dimension(500,100));
		distPicPanel.add(new JLabel( new ImageIcon(ClassLoader.getSystemResource(imgName)) ));
		distForcesPane.add(distPicPanel);
		
		distButPane.setLayout(distCardManager);
		
		JPanel distBut1Pane = new JPanel();
		distBut1Pane.setLayout(new GridLayout(1,2,2,2));
        distBut1Pane.setMaximumSize(new Dimension(500,120));
		JPanel distBut1aPane = new JPanel();
		distBut1aPane.setLayout(new GridLayout(1,2,2,2));
		distBut1aPane.add(distNewButton);
		distBut1aPane.add(distModButton);
		distBut1Pane.add(distListCombo);
		distBut1Pane.add(distBut1aPane);
		
		JPanel distBut2Pane = new JPanel();
		distBut2Pane.setLayout(new GridLayout(1,2,2,2));
        distBut2Pane.setMaximumSize(new Dimension(500,120));
		distBut2Pane.add(distLabelField);
		JPanel distBut2aPane = new JPanel();
		distBut2aPane.setLayout(new GridLayout(1,2,2,2));
		distBut2aPane.add(distOkButton);
		distBut2aPane.add(distCancButton);
		distBut2Pane.add(distBut2aPane);
		
		distButPane.add(distBut1Pane, "distCombo");
		distButPane.add(distBut2Pane, "distLabel");
		
		distForcesPane.add(distButPane);
		
		JPanel distDistPane = new JPanel();
		distDistPane.setLayout(new GridLayout(1,2,2,2));
        distDistPane.setMaximumSize(new Dimension(500,80));
		distDistPane.setBorder(BorderFactory.createCompoundBorder(
			BorderFactory.createTitledBorder(parent.getResourceBundle().getString("dElmDistForDialog01")),
			BorderFactory.createEmptyBorder(2,2,2,2)));
		JPanel distAPane = new JPanel();
		distAPane.add(new JLabel("A:"));
		distAPane.add(distAField);
		distDistPane.add(distAPane);
		JPanel distBPane = new JPanel();
		distBPane.add(new JLabel("B:"));
		distBPane.add(distBField);
		distDistPane.add(distBPane);
		distForcesPane.add(distDistPane);
		
		JPanel distValuesPanel = new JPanel();
		distValuesPanel.setLayout(new GridLayout(1,2,0,0));
		
		JPanel distValues1Pane = new JPanel();
		distValues1Pane.setLayout(new GridLayout(4,1,2,2));
        distValues1Pane.setMaximumSize(new Dimension(500,300));
		distValues1Pane.setBorder(BorderFactory.createCompoundBorder(
			BorderFactory.createTitledBorder(parent.getResourceBundle().getString("dElmDistForDialog02")),
			BorderFactory.createEmptyBorder(2,2,2,2)));
		
		JPanel distFx1Panel = new JPanel();
		distFx1Panel.add(new JLabel("Fx:"));
		distFx1Panel.add(distFx1Field);
		distValues1Pane.add(distFx1Panel);
		JPanel distFy1Panel = new JPanel();
		distFy1Panel.add(new JLabel("Fy:"));
		distFy1Panel.add(distFy1Field);
		distValues1Pane.add(distFy1Panel);
		JPanel distFz1Panel = new JPanel();
		distFz1Panel.add(new JLabel("Fz:"));
		distFz1Panel.add(distFz1Field);
		distValues1Pane.add(distFz1Panel);
		JPanel distMx1Panel = new JPanel();
		distMx1Panel.add(new JLabel("Mx:"));
		distMx1Panel.add(distMx1Field);
		distValues1Pane.add(distMx1Panel);
		
		distValuesPanel.add(distValues1Pane);
		
		JPanel distValues2Pane = new JPanel();
		distValues2Pane.setLayout(new GridLayout(4,1,2,2));
        distValues2Pane.setMaximumSize(new Dimension(500,300));
		distValues2Pane.setBorder(BorderFactory.createCompoundBorder(
			BorderFactory.createTitledBorder(parent.getResourceBundle().getString("dElmDistForDialog03")),
			BorderFactory.createEmptyBorder(2,2,2,2)));
		
		JPanel distFx2Panel = new JPanel();
		distFx2Panel.add(new JLabel("Fx:"));
		distFx2Panel.add(distFx2Field);
		distValues2Pane.add(distFx2Panel);
		JPanel distFy2Panel = new JPanel();
		distFy2Panel.add(new JLabel("Fy:"));
		distFy2Panel.add(distFy2Field);
		distValues2Pane.add(distFy2Panel);
		JPanel distFz2Panel = new JPanel();
		distFz2Panel.add(new JLabel("Fz:"));
		distFz2Panel.add(distFz2Field);
		distValues2Pane.add(distFz2Panel);
		JPanel distMx2Panel = new JPanel();
		distMx2Panel.add(new JLabel("Mx:"));
		distMx2Panel.add(distMx2Field);
		distValues2Pane.add(distMx2Panel);
		
		distValuesPanel.add(distValues2Pane);
		distForcesPane.add(distValuesPanel);
		
		//Sets up the temperature panel
		JPanel temperaturePane = new JPanel();
		temperaturePane.setPreferredSize(new Dimension(360,280));
		temperaturePane.setLayout(new BoxLayout(temperaturePane, BoxLayout.Y_AXIS));
		
		JPanel tempPicPane = new JPanel();
		tempPicPane.setMaximumSize(new Dimension(500,100));
		imgName = "br/ufmg/dees/insane/images/" + parent.getResourceBundle().getString("imgThermal100");
		tempPicPane.add(new JLabel( new ImageIcon(ClassLoader.getSystemResource(imgName)) ));
		temperaturePane.add(tempPicPane);
		
		JPanel tempPane = new JPanel();
		tempPane.setLayout(new GridLayout(3,1,2,2));
        tempPane.setMaximumSize(new Dimension(500,120));
		tempPane.setBorder(BorderFactory.createCompoundBorder(
			BorderFactory.createTitledBorder(parent.getResourceBundle().getString("dETempChanDialog01")),
			BorderFactory.createEmptyBorder(2,2,2,2)));
		
		JPanel tempTSPane = new JPanel();
		tempTSPane.add(new JLabel("Ts:"));
		tempTSPane.add(TsField);
		tempPane.add(tempTSPane);
		
		JPanel tempTNPane = new JPanel();
		tempTNPane.add(new JLabel("Tn:"));
		tempTNPane.add(TnField);
		tempPane.add(tempTNPane);
		
		JPanel tempTIPane = new JPanel();
		tempTIPane.add(new JLabel("Ti:"));
		tempTIPane.add(TiField);
		tempPane.add(tempTIPane);
		
		temperaturePane.add(tempPane);
		
		//Sets up the liberations panel
		JPanel liberationsPane = new JPanel();
		liberationsPane.setPreferredSize(new Dimension(360,280));
		liberationsPane.setLayout(new BoxLayout(liberationsPane, BoxLayout.Y_AXIS));
		
		JPanel libPicPane = new JPanel();
		libPicPane.setMaximumSize(new Dimension(500,100));
		libPicPane.add(new JLabel( new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Liberation100.gif")) ));
		liberationsPane.add(libPicPane);
		
		JPanel lib1Pane = new JPanel();
		lib1Pane.setLayout(new GridLayout(2,3,2,2));
		lib1Pane.setMaximumSize(new Dimension(500,90));
		lib1Pane.setBorder(BorderFactory.createCompoundBorder(
			BorderFactory.createTitledBorder(parent.getResourceBundle().getString("dElmElaConDialog01")),
			BorderFactory.createEmptyBorder(2,2,2,2)));
		
		JPanel libD1xPane = new JPanel();
		JPanel libD1yPane = new JPanel();
		JPanel libD1zPane = new JPanel();
		libD1xPane.add(new JLabel("Dx:"));
		libD1xPane.add(liberationLdx1);
		libD1yPane.add(new JLabel("Dy:"));
		libD1yPane.add(liberationLdy1);
		libD1zPane.add(new JLabel("Dz:"));
		libD1zPane.add(liberationLdz1);
		lib1Pane.add(libD1xPane);
		lib1Pane.add(libD1yPane);
		lib1Pane.add(libD1zPane);
		
		JPanel libR1xPane = new JPanel();
		JPanel libR1yPane = new JPanel();
		JPanel libR1zPane = new JPanel();
		libR1xPane.add(new JLabel("Rx:"));
		libR1xPane.add(liberationLrx1);
		libR1yPane.add(new JLabel("Ry:"));
		libR1yPane.add(liberationLry1);
		libR1zPane.add(new JLabel("Rz:"));
		libR1zPane.add(liberationLrz1);
		lib1Pane.add(libR1xPane);
		lib1Pane.add(libR1yPane);
		lib1Pane.add(libR1zPane);
		liberationsPane.add(lib1Pane);
		
		JPanel lib2Pane = new JPanel();
		lib2Pane.setLayout(new GridLayout(2,3,2,2));
		lib2Pane.setMaximumSize(new Dimension(500,90));
        lib2Pane.setBorder(BorderFactory.createCompoundBorder(
        	BorderFactory.createTitledBorder(parent.getResourceBundle().getString("dElmElaConDialog02")),
			BorderFactory.createEmptyBorder(2,2,2,2)));
		
		JPanel libD2xPane = new JPanel();
		JPanel libD2yPane = new JPanel();
		JPanel libD2zPane = new JPanel();
		libD2xPane.add(new JLabel("Dx:"));
		libD2xPane.add(liberationLdx2);
		libD2yPane.add(new JLabel("Dy:"));
		libD2yPane.add(liberationLdy2);
		libD2zPane.add(new JLabel("Dz:"));
		libD2zPane.add(liberationLdz2);
		lib2Pane.add(libD2xPane);
		lib2Pane.add(libD2yPane);
		lib2Pane.add(libD2zPane);
		
		JPanel libR2xPane = new JPanel();
		JPanel libR2yPane = new JPanel();
		JPanel libR2zPane = new JPanel();
		libR2xPane.add(new JLabel("Rx:"));
		libR2xPane.add(liberationLrx2);
		libR2yPane.add(new JLabel("Ry:"));
		libR2yPane.add(liberationLry2);
		libR2zPane.add(new JLabel("Rz:"));
		libR2zPane.add(liberationLrz2);
		lib2Pane.add(libR2xPane);
		lib2Pane.add(libR2yPane);
		lib2Pane.add(libR2zPane);
		liberationsPane.add(lib2Pane);
		
		//Sets up the pre-strains panel
		JPanel preStrainsPane = new JPanel();
		preStrainsPane.setPreferredSize(new Dimension(360,280));
		preStrainsPane.setLayout(new BoxLayout(preStrainsPane, BoxLayout.Y_AXIS));
		
		JPanel psPicPane = new JPanel();
		psPicPane.setMaximumSize(new Dimension(500,100));
		psPicPane.add(new JLabel( new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/PreStrains100.gif")) ));
		preStrainsPane.add(psPicPane);
		
		JPanel ps1Pane = new JPanel();
		ps1Pane.setLayout(new GridLayout(2,3,2,2));
		ps1Pane.setMaximumSize(new Dimension(500,90));
		ps1Pane.setBorder(BorderFactory.createCompoundBorder(
			BorderFactory.createTitledBorder(parent.getResourceBundle().getString("dElmElaConDialog01")),
			BorderFactory.createEmptyBorder(2,2,2,2)));
			
		JPanel psD1xPane = new JPanel();
		JPanel psD1yPane = new JPanel();
		JPanel psD1zPane = new JPanel();
		psD1xPane.add(new JLabel("Dx:"));
		psD1xPane.add(psDx1Field);
		psD1yPane.add(new JLabel("Dy:"));
		psD1yPane.add(psDy1Field);
		psD1zPane.add(new JLabel("Dz:"));
		psD1zPane.add(psDz1Field);
		ps1Pane.add(psD1xPane);
		ps1Pane.add(psD1yPane);
		ps1Pane.add(psD1zPane);
		
		JPanel psR1xPane = new JPanel();
		JPanel psR1yPane = new JPanel();
		JPanel psR1zPane = new JPanel();
		psR1xPane.add(new JLabel("Rx:"));
		psR1xPane.add(psRx1Field);
		psR1yPane.add(new JLabel("Ry:"));
		psR1yPane.add(psRy1Field);
		psR1zPane.add(new JLabel("Rz:"));
		psR1zPane.add(psRz1Field);
		ps1Pane.add(psR1xPane);
		ps1Pane.add(psR1yPane);
		ps1Pane.add(psR1zPane);
		
		JPanel ps2Pane = new JPanel();
		ps2Pane.setLayout(new GridLayout(2,3,2,2));
		ps2Pane.setMaximumSize(new Dimension(500,90));
		ps2Pane.setBorder(BorderFactory.createCompoundBorder(
			BorderFactory.createTitledBorder(parent.getResourceBundle().getString("dElmElaConDialog02")),
			BorderFactory.createEmptyBorder(2,2,2,2)));
		
		JPanel psD2xPane = new JPanel();
		JPanel psD2yPane = new JPanel();
		JPanel psD2zPane = new JPanel();
		psD2xPane.add(new JLabel("Dx:"));
		psD2xPane.add(psDx2Field);
		psD2yPane.add(new JLabel("Dy:"));
		psD2yPane.add(psDy2Field);
		psD2zPane.add(new JLabel("Dz:"));
		psD2zPane.add(psDz2Field);
		ps2Pane.add(psD2xPane);
		ps2Pane.add(psD2yPane);
		ps2Pane.add(psD2zPane);
		
		JPanel psR2xPane = new JPanel();
		JPanel psR2yPane = new JPanel();
		JPanel psR2zPane = new JPanel();
		psR2xPane.add(new JLabel("Rx:"));
		psR2xPane.add(psRx2Field);
		psR2yPane.add(new JLabel("Ry:"));
		psR2yPane.add(psRy2Field);
		psR2zPane.add(new JLabel("Rz:"));
		psR2zPane.add(psRz2Field);
		ps2Pane.add(psR2xPane);
		ps2Pane.add(psR2yPane);
		ps2Pane.add(psR2zPane);
		
		preStrainsPane.add(ps1Pane);
		preStrainsPane.add(ps2Pane);
		
		//Sets up the initial equivalent nodal forces panel
		JPanel iniEqNForcesPane = new JPanel();
		iniEqNForcesPane.setPreferredSize(new Dimension(360,280));
		iniEqNForcesPane.setLayout(new BoxLayout(iniEqNForcesPane, BoxLayout.Y_AXIS));
		
		JPanel eqPicPane = new JPanel();
		eqPicPane.setMaximumSize(new Dimension(500,100));
		eqPicPane.add(new JLabel( new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/IniEqForce100.gif")) ));
		iniEqNForcesPane.add(eqPicPane);
		
		JPanel eq1Pane = new JPanel();
		eq1Pane.setLayout(new GridLayout(2,3,2,2));
		eq1Pane.setMaximumSize(new Dimension(500,90));
		eq1Pane.setBorder(BorderFactory.createCompoundBorder(
			BorderFactory.createTitledBorder(parent.getResourceBundle().getString("dElmElaConDialog01")),
			BorderFactory.createEmptyBorder(2,2,2,2)));
			
		JPanel eqF1xPane = new JPanel();
		JPanel eqF1yPane = new JPanel();
		JPanel eqF1zPane = new JPanel();
		eqF1xPane.add(new JLabel("Fx:"));
		eqF1xPane.add(eqFx1Field);
		eqF1yPane.add(new JLabel("Fy:"));
		eqF1yPane.add(eqFy1Field);
		eqF1zPane.add(new JLabel("Fz:"));
		eqF1zPane.add(eqFz1Field);
		eq1Pane.add(eqF1xPane);
		eq1Pane.add(eqF1yPane);
		eq1Pane.add(eqF1zPane);
		
		JPanel eqM1xPane = new JPanel();
		JPanel eqM1yPane = new JPanel();
		JPanel eqM1zPane = new JPanel();
		eqM1xPane.add(new JLabel("Mx:"));
		eqM1xPane.add(eqMx1Field);
		eqM1yPane.add(new JLabel("My:"));
		eqM1yPane.add(eqMy1Field);
		eqM1zPane.add(new JLabel("Mz:"));
		eqM1zPane.add(eqMz1Field);
		eq1Pane.add(eqM1xPane);
		eq1Pane.add(eqM1yPane);
		eq1Pane.add(eqM1zPane);
		iniEqNForcesPane.add(eq1Pane);
		
		JPanel eq2Pane = new JPanel();
		eq2Pane.setLayout(new GridLayout(2,3,2,2));
		eq2Pane.setMaximumSize(new Dimension(500,90));
		eq2Pane.setBorder(BorderFactory.createCompoundBorder(
			BorderFactory.createTitledBorder(parent.getResourceBundle().getString("dElmElaConDialog02")),
			BorderFactory.createEmptyBorder(2,2,2,2)));
			
		JPanel eqF2xPane = new JPanel();
		JPanel eqF2yPane = new JPanel();
		JPanel eqF2zPane = new JPanel();
		eqF2xPane.add(new JLabel("Fx:"));
		eqF2xPane.add(eqFx2Field);
		eqF2yPane.add(new JLabel("Fy:"));
		eqF2yPane.add(eqFy2Field);
		eqF2zPane.add(new JLabel("Fz:"));
		eqF2zPane.add(eqFz2Field);
		eq2Pane.add(eqF2xPane);
		eq2Pane.add(eqF2yPane);
		eq2Pane.add(eqF2zPane);
		
		JPanel eqM2xPane = new JPanel();
		JPanel eqM2yPane = new JPanel();
		JPanel eqM2zPane = new JPanel();
		eqM2xPane.add(new JLabel("Mx:"));
		eqM2xPane.add(eqMx2Field);
		eqM2yPane.add(new JLabel("My:"));
		eqM2yPane.add(eqMy2Field);
		eqM2zPane.add(new JLabel("Mz:"));
		eqM2zPane.add(eqMz2Field);
		eq2Pane.add(eqM2xPane);
		eq2Pane.add(eqM2yPane);
		eq2Pane.add(eqM2zPane);
		iniEqNForcesPane.add(eq2Pane);
		
		addTab(parent.getResourceBundle().getString("dElmAttDialog01"), generalPane);
		addTab(parent.getResourceBundle().getString("mConcForces"), concForcesPane);
		addTab(parent.getResourceBundle().getString("mDistForces"), distForcesPane);
		addTab(parent.getResourceBundle().getString("mTempChanges"), temperaturePane);
		addTab(parent.getResourceBundle().getString("mLiberations"), liberationsPane);
		addTab(parent.getResourceBundle().getString("mPreStrains"), preStrainsPane);
		addTab(parent.getResourceBundle().getString("mIniEqNodForces"), iniEqNForcesPane);
		
    }
	
//*****************************************************************************
	
    public int showDialog() {
    	return super.showDialog(parent, parent.getResourceBundle().getString("dElmAttDialog02"));
    }
	
//*****************************************************************************
	
	/**
	 * This method is executed on OK button click.
	 */
	public void approvedPerform() {
		
		try {
			int anlIndex = analysisTypeCombo.getSelectedIndex();
			anlTypeChosen = analysisTypeStr[anlIndex];
			
			int matIndex = matListCombo.getSelectedIndex();
			if (matIndex>0)
				matLabel = ((LinearElasticIsotropic)fmodel.getMaterialsList().get(matIndex-1)).getLabel();
			else matLabel = null;
			
			int secIndex = secListCombo.getSelectedIndex();
			if (secIndex>0)
				secLabel = ((CrossSection)fmodel.getSectionsList().get(secIndex-1)).getLabel();
			else secLabel = null;
			
			Ts = TsField.getValue();
			Tn = TnField.getValue();
			Ti = TiField.getValue();
			
			eqFx1 = eqFx1Field.getValue();
			eqFy1 = eqFy1Field.getValue();
			eqFz1 = eqFz1Field.getValue();
			eqMx1 = eqMx1Field.getValue();
			eqMy1 = eqMy1Field.getValue();
			eqMz1 = eqMz1Field.getValue();
			eqFx2 = eqFx2Field.getValue();
			eqFy2 = eqFy2Field.getValue();
			eqFz2 = eqFz2Field.getValue();
			eqMx2 = eqMx2Field.getValue();
			eqMy2 = eqMy2Field.getValue();
			eqMz2 = eqMz2Field.getValue();
			
			psDx1 = psDx1Field.getValue();
			psDy1 = psDy1Field.getValue();
			psDz1 = psDz1Field.getValue();
			psRx1 = psRx1Field.getValue();
			psRy1 = psRy1Field.getValue();
			psRz1 = psRz1Field.getValue();
			psDx2 = psDx2Field.getValue();
			psDy2 = psDy2Field.getValue();
			psDz2 = psDz2Field.getValue();
			psRx2 = psRx2Field.getValue();
			psRy2 = psRy2Field.getValue();
			psRz2 = psRz2Field.getValue();
			
			Ldx1 = liberationLdx1.isSelected();
			Ldy1 = liberationLdy1.isSelected();
			Ldz1 = liberationLdz1.isSelected();
			Lrx1 = liberationLrx1.isSelected();
			Lry1 = liberationLry1.isSelected();
			Lrz1 = liberationLrz1.isSelected();
			Ldx2 = liberationLdx2.isSelected();
			Ldy2 = liberationLdy2.isSelected();
			Ldz2 = liberationLdz2.isSelected();
			Lrx2 = liberationLrx2.isSelected();
			Lry2 = liberationLry2.isSelected();
			Lrz2 = liberationLrz2.isSelected();
			
		} catch (Exception e) {
			Toolkit.getDefaultToolkit().beep();
			this.setVisible(false);
		}
	}
	
//*****************************************************************************
	
	/**
	 * Sets up the number formater
	 */
	private void setUpFormat() {
		numberFormat = (DecimalFormat)NumberFormat.getNumberInstance(Locale.UK);
		numberFormat.setMinimumFractionDigits(parent.getModelState().getPrecision());
		numberFormat.setMaximumFractionDigits(8);
		
		numberFormat2 = (DecimalFormat)NumberFormat.getNumberInstance(Locale.UK);
		numberFormat2.setMinimumFractionDigits(parent.getModelState().getPrecision());
		numberFormat2.setMaximumFractionDigits(parent.getModelState().getPrecision());
	}
	
//*****************************************************************************
	
	/**
	 * Sets up fields
	 */
	@SuppressWarnings("unchecked")
	private void setUpFields() {
		
		//Checking if it's possible to choose an analysis model for the element different
		//from the global analysis model
		if (fmodel.getGlobalAnalysisModel().getType().equals("Beam")) {
			analysisTypeCombo.setSelectedIndex(0);
			analysisTypeCombo.setEnabled(false);
		} else if (fmodel.getGlobalAnalysisModel().getType().equals("PlaneTruss")) {
			analysisTypeCombo.setSelectedIndex(2);
			analysisTypeCombo.setEnabled(false);
		} else if (fmodel.getGlobalAnalysisModel().getType().equals("Grid")) {
			analysisTypeCombo.setSelectedIndex(0);
			analysisTypeCombo.setEnabled(false);
		}
		
		if (this.parent.getController().getSelection().size() == 1 ) {
			
			FrameElement elm = (FrameElement)this.parent.getController().getSelection().get(0);
			
			//Setting analysis model field
			String str = elm.getAnalysisModel().getType();
			if (str.equals("Beam"))
				analysisTypeCombo.setSelectedIndex(0);
			else if (str.equals("PlaneFrame"))
				analysisTypeCombo.setSelectedIndex(1);
			else if (str.equals("PlaneTruss"))
				analysisTypeCombo.setSelectedIndex(2);
			else if (str.equals("Grid"))
				analysisTypeCombo.setSelectedIndex(0);
			
			//Setting material fields
			if (elm.getMaterial() != null)
				str = elm.getMaterial().getLabel();
			else str = "";
			int num = fmodel.getNumberOfMaterials();
			int matIndex = 0;
			for (int i=0; i<num; i++) {
				if (str.equals(matLabelList[i+1]))
					matIndex = i+1;
			}
			matListCombo.setSelectedIndex(matIndex);
			try {
			    LinearElasticIsotropic mat = (LinearElasticIsotropic)elm.getMaterial();
				matEField = new DecimalField(mat.getMaterialValues(mat.ELASTICITY).doubleValue(), 7, numberFormat);
				matGField = new DecimalField(mat.getMaterialValues(mat.SHEAR_MODULUS).doubleValue(), 7, numberFormat);
				matPoissonField = new DecimalField(mat.getMaterialValues(mat.POISSON).doubleValue(), 7, numberFormat);
				matThermalField = new DecimalField(mat.getMaterialValues(mat.THERMAL_COEFF).doubleValue(), 7, numberFormat);
			} catch (Exception e) {
				matEField = new DecimalField(0, 7, numberFormat);
				matGField = new DecimalField(0, 7, numberFormat);
				matPoissonField = new DecimalField(0, 7, numberFormat);
				matThermalField = new DecimalField(0, 7, numberFormat);
				matEField.setText(" ");
				matGField.setText(" ");
				matPoissonField.setText(" ");
				matThermalField.setText(" ");
			}
			
			//Setting cross section fields
			if (elm.getCrossSection() != null)
				str = elm.getCrossSection().getLabel();
			else str = "";
			num = fmodel.getNumberOfSections();
			int secIndex = 0;
			for (int i=0; i<num; i++) {
				if (str.equals(secLabelList[i+1]))
					secIndex = i+1;
			}
			secListCombo.setSelectedIndex(secIndex);
			try {
				CrossSection cs = elm.getCrossSection();
				secIxField = new DecimalField(cs.getIx(), 7, numberFormat);
				secIyField = new DecimalField(cs.getIy(), 7, numberFormat);
				secIzField = new DecimalField(cs.getIz(), 7, numberFormat);
				secAField = new DecimalField(cs.getArea(), 7, numberFormat);
				secHField = new DecimalField(cs.getHeight(), 7, numberFormat);
				secThickField = new DecimalField(cs.getThickness(), 7, numberFormat);
			} catch (Exception e) {
				secIxField = new DecimalField(0, 7, numberFormat);
				secIyField = new DecimalField(0, 7, numberFormat);
				secIzField = new DecimalField(0, 7, numberFormat);
				secAField = new DecimalField(0, 7, numberFormat);
				secHField = new DecimalField(0, 7, numberFormat);
				secThickField = new DecimalField(0, 7, numberFormat);
				secIxField.setText(" ");
				secIyField.setText(" ");
				secIzField.setText(" ");
				secAField.setText(" ");
				secHField.setText(" ");
				secThickField.setText(" ");
			}
			
			//Setting concentrated forces fields
			concForces = (ArrayList<PointForce>)elm.getElmPointForcesList().clone();
			
			String txt = parent.getResourceBundle().getString("dEConcForDialog04") + " = ";
			String txt2 = numberFormat2.format(elm.getLength());
			txt = txt + txt2;
			concLLabel.setText(txt);
			
			//Copying actual ElmPointForcesList
			ListIterator pfs = elm.getElmPointForcesList().listIterator();
			while (pfs.hasNext()) {
				
				PointForce pf1 = (PointForce)pfs.next();
				PointForce pf2 = new PointForce();
				
				pf2.getCoord().x = pf1.getCoord().x;
				pf2.setForce(0, pf1.getForce(0));
				pf2.setForce(1, pf1.getForce(1));
				pf2.setForce(2, pf1.getForce(2));
				pf2.setForce(3, pf1.getForce(3));
				pf2.setForce(4, pf1.getForce(4));
				pf2.setForce(5, pf1.getForce(5));
				
				concForces.add(pf2);
			}
			
			if (concForces.size() > 0) {
				PointForce force = (PointForce)concForces.get(0);
				concAField = new DecimalField(force.getCoord().x, 7, numberFormat);
				concFxField = new DecimalField(force.getForce(0), 7, numberFormat);
				concFyField = new DecimalField(force.getForce(1), 7, numberFormat);
				concFzField = new DecimalField(force.getForce(2), 7, numberFormat);
				concMxField = new DecimalField(force.getForce(3), 7, numberFormat);
				concMyField = new DecimalField(force.getForce(4), 7, numberFormat);
				concMzField = new DecimalField(force.getForce(5), 7, numberFormat);
			} else {
				concAField = new DecimalField(0, 7, numberFormat);
				concFxField = new DecimalField(0, 7, numberFormat);
				concFyField = new DecimalField(0, 7, numberFormat);
				concFzField = new DecimalField(0, 7, numberFormat);
				concMxField = new DecimalField(0, 7, numberFormat);
				concMyField = new DecimalField(0, 7, numberFormat);
				concMzField = new DecimalField(0, 7, numberFormat);
				concAField.setText("");
				concFxField.setText("");
				concFyField.setText("");
				concFzField.setText("");
				concMxField.setText("");
				concMyField.setText("");
				concMzField.setText("");
				concModButton.setEnabled(false);
				
			}
			
			//Setting distributed forces fields
			//Copying actual ElmLineForcesList
			ListIterator efs = elm.getElmLineForcesList().listIterator();
			while (efs.hasNext()) {
				
				ElementForce ef1 = (ElementForce)efs.next();
				ElementForce ef2 = new ElementForce();
				PointForce pf1a = (PointForce)ef1.getPointForcesList().get(0);
				PointForce pf1b = (PointForce)ef1.getPointForcesList().get(1);
				PointForce pf2a = new PointForce();
				PointForce pf2b = new PointForce();
				
				pf2a.getCoord().x = pf1a.getCoord().x;
				pf2a.setForce(0, pf1a.getForce(0));
				pf2a.setForce(1, pf1a.getForce(1));
				pf2a.setForce(2, pf1a.getForce(2));
				pf2a.setForce(3, pf1a.getForce(3));
				pf2a.setForce(4, pf1a.getForce(4));
				pf2a.setForce(5, pf1a.getForce(5));
				
				pf2b.getCoord().x = pf1b.getCoord().x;
				pf2b.setForce(0, pf1b.getForce(0));
				pf2b.setForce(1, pf1b.getForce(1));
				pf2b.setForce(2, pf1b.getForce(2));
				pf2b.setForce(3, pf1b.getForce(3));
				pf2b.setForce(4, pf1b.getForce(4));
				pf2b.setForce(5, pf1b.getForce(5));
				
				ef2.getPointForcesList().add(0, pf2a);
				ef2.getPointForcesList().add(1, pf2b);
				
				distForces.add(ef2);
			}
			
			if (distForces.size() > 0) {
				ElementForce dforce = (ElementForce)distForces.get(0);
				PointForce iforce = (PointForce)dforce.getPointForcesList().get(0);
				PointForce fforce = (PointForce)dforce.getPointForcesList().get(1);
				distAField = new DecimalField(iforce.getCoord().x, 7, numberFormat);
				distBField = new DecimalField(fforce.getCoord().x, 7, numberFormat);
				distFx1Field = new DecimalField(iforce.getForce(0), 7, numberFormat);
				distFy1Field = new DecimalField(iforce.getForce(1), 7, numberFormat);
				distFz1Field = new DecimalField(iforce.getForce(2), 7, numberFormat);
				distMx1Field = new DecimalField(iforce.getForce(3), 7, numberFormat);
				distFx2Field = new DecimalField(fforce.getForce(0), 7, numberFormat);
				distFy2Field = new DecimalField(fforce.getForce(1), 7, numberFormat);
				distFz2Field = new DecimalField(fforce.getForce(2), 7, numberFormat);
				distMx2Field = new DecimalField(fforce.getForce(3), 7, numberFormat);
			} else {
				distAField = new DecimalField(0, 7, numberFormat);
				distBField = new DecimalField(0, 7, numberFormat);
				distFx1Field = new DecimalField(0, 7, numberFormat);
				distFy1Field = new DecimalField(0, 7, numberFormat);
				distFz1Field = new DecimalField(0, 7, numberFormat);
				distMx1Field = new DecimalField(0, 7, numberFormat);
				distFx2Field = new DecimalField(0, 7, numberFormat);
				distFy2Field = new DecimalField(0, 7, numberFormat);
				distFz2Field = new DecimalField(0, 7, numberFormat);
				distMx2Field = new DecimalField(0, 7, numberFormat);
				distAField.setText("");
				distBField.setText("");
				distFx1Field.setText("");
				distFy1Field.setText("");
				distFz1Field.setText("");
				distMx1Field.setText("");
				distFx2Field.setText("");
				distFy2Field.setText("");
				distFz2Field.setText("");
				distMx2Field.setText("");
				distModButton.setEnabled(false);
				
			}
			
			//Setting temperature fields
			TsField = new DecimalField(elm.getDeltaTemp(0), 7, numberFormat);
			TnField = new DecimalField(elm.getDeltaTemp(1), 7, numberFormat);
			TiField = new DecimalField(elm.getDeltaTemp(2), 7, numberFormat);
			
			if (elm.getCrossSection()!=null && elm.getCrossSection().getHeight()!=0 && elm.getMaterial()!=null && matThermalField.getValue()!=0) {
				if (elm.getAnalysisModel().getType().equals("Beam")) {
					TsField.setEnabled(true);
					TnField.setEnabled(false);
					TiField.setEnabled(true);
				}else if (elm.getAnalysisModel().getType().equals("PlaneFrame")) {
					TsField.setEnabled(true);
					TnField.setEnabled(true);
					TiField.setEnabled(true);
				} else if (elm.getAnalysisModel().getType().equals("PlaneTruss")) {
					TsField.setEnabled(false);
					TnField.setEnabled(true);
					TiField.setEnabled(false);
				}
			} else {
				TsField.setEnabled(false);
				TnField.setEnabled(false);
				TiField.setEnabled(false);
			}
			
			//Setting initial equivalent nodal forces fields
			eqFx1Field = new DecimalField(elm.getInitialNodalForce(0), 7, numberFormat);
			eqFy1Field = new DecimalField(elm.getInitialNodalForce(1), 7, numberFormat);
			eqFz1Field = new DecimalField(elm.getInitialNodalForce(2), 7, numberFormat);
			eqMx1Field = new DecimalField(elm.getInitialNodalForce(3), 7, numberFormat);
			eqMy1Field = new DecimalField(elm.getInitialNodalForce(4), 7, numberFormat);
			eqMz1Field = new DecimalField(elm.getInitialNodalForce(5), 7, numberFormat);
			eqFx2Field = new DecimalField(elm.getInitialNodalForce(6), 7, numberFormat);
			eqFy2Field = new DecimalField(elm.getInitialNodalForce(7), 7, numberFormat);
			eqFz2Field = new DecimalField(elm.getInitialNodalForce(8), 7, numberFormat);
			eqMx2Field = new DecimalField(elm.getInitialNodalForce(9), 7, numberFormat);
			eqMy2Field = new DecimalField(elm.getInitialNodalForce(10), 7, numberFormat);
			eqMz2Field = new DecimalField(elm.getInitialNodalForce(11), 7, numberFormat);
			
			//Setting pre-strains fields
			psDx1Field = new DecimalField(elm.getElmPreDisplacement(0), 7, numberFormat);
			psDy1Field = new DecimalField(elm.getElmPreDisplacement(1), 7, numberFormat);
			psDz1Field = new DecimalField(elm.getElmPreDisplacement(2), 7, numberFormat);
			psRx1Field = new DecimalField(elm.getElmPreDisplacement(3), 7, numberFormat);
			psRy1Field = new DecimalField(elm.getElmPreDisplacement(4), 7, numberFormat);
			psRz1Field = new DecimalField(elm.getElmPreDisplacement(5), 7, numberFormat);
			psDx2Field = new DecimalField(elm.getElmPreDisplacement(6), 7, numberFormat);
			psDy2Field = new DecimalField(elm.getElmPreDisplacement(7), 7, numberFormat);
			psDz2Field = new DecimalField(elm.getElmPreDisplacement(8), 7, numberFormat);
			psRx2Field = new DecimalField(elm.getElmPreDisplacement(9), 7, numberFormat);
			psRy2Field = new DecimalField(elm.getElmPreDisplacement(10), 7, numberFormat);
			psRz2Field = new DecimalField(elm.getElmPreDisplacement(11), 7, numberFormat);
			
			//Setting liberations fields
			liberationLdx1.setSelected(elm.getLiberation(0));
			liberationLdy1.setSelected(elm.getLiberation(1));
			liberationLdz1.setSelected(elm.getLiberation(2));
			liberationLrx1.setSelected(elm.getLiberation(3));
			liberationLry1.setSelected(elm.getLiberation(4));
			liberationLrz1.setSelected(elm.getLiberation(5));
			liberationLdx2.setSelected(elm.getLiberation(6));
			liberationLdy2.setSelected(elm.getLiberation(7));
			liberationLdz2.setSelected(elm.getLiberation(8));
			liberationLrx2.setSelected(elm.getLiberation(9));
			liberationLry2.setSelected(elm.getLiberation(10));
			liberationLrz2.setSelected(elm.getLiberation(11));
			
		} else {
			
			//Setting analysis model field
			String str = fmodel.getGlobalAnalysisModel().getType();
			if (str.equals("Beam"))
				analysisTypeCombo.setSelectedIndex(0);
			else if (str.equals("PlaneFrame"))
				analysisTypeCombo.setSelectedIndex(1);
			else if (str.equals("PlaneTruss"))
				analysisTypeCombo.setSelectedIndex(2);
			else if (str.equals("Grid"))
				analysisTypeCombo.setSelectedIndex(0);
			
			//Setting material fields
			matEField = new DecimalField(0, 7, numberFormat);
			matGField = new DecimalField(0, 7, numberFormat);
			matPoissonField = new DecimalField(0, 7, numberFormat);
			matThermalField = new DecimalField(0, 7, numberFormat);
			matListCombo.setSelectedIndex(0);
			matEField.setText(" ");
			matGField.setText(" ");
			matPoissonField.setText(" ");
			matThermalField.setText(" ");
			
			//Setting cross section fields
			secIxField = new DecimalField(0, 7, numberFormat);
			secIyField = new DecimalField(0, 7, numberFormat);
			secIzField = new DecimalField(0, 7, numberFormat);
			secAField = new DecimalField(0, 7, numberFormat);
			secHField = new DecimalField(0, 7, numberFormat);
			secListCombo.setSelectedIndex(0);
			secIxField.setText(" ");
			secIyField.setText(" ");
			secIzField.setText(" ");
			secAField.setText(" ");
			secHField.setText(" ");
			
			//Setting concentrated forces fields
			concAField = new DecimalField(0, 7, numberFormat);
			concFxField = new DecimalField(0, 7, numberFormat);
			concFyField = new DecimalField(0, 7, numberFormat);
			concFzField = new DecimalField(0, 7, numberFormat);
			concMxField = new DecimalField(0, 7, numberFormat);
			concMyField = new DecimalField(0, 7, numberFormat);
			concMzField = new DecimalField(0, 7, numberFormat);
			concAField.setText("");
			String txt = parent.getResourceBundle().getString("dEConcForDialog04") + " = N/A";
			concLLabel.setText(txt);
			concFxField.setText("");
			concFyField.setText("");
			concFzField.setText("");
			concMxField.setText("");
			concMyField.setText("");
			concMzField.setText("");
			concModButton.setEnabled(false);
			
			//Setting distributed forces fields
			distAField = new DecimalField(0, 7, numberFormat);
			distBField = new DecimalField(0, 7, numberFormat);
			distFx1Field = new DecimalField(0, 7, numberFormat);
			distFy1Field = new DecimalField(0, 7, numberFormat);
			distFz1Field = new DecimalField(0, 7, numberFormat);
			distMx1Field = new DecimalField(0, 7, numberFormat);
			distFx2Field = new DecimalField(0, 7, numberFormat);
			distFy2Field = new DecimalField(0, 7, numberFormat);
			distFz2Field = new DecimalField(0, 7, numberFormat);
			distMx2Field = new DecimalField(0, 7, numberFormat);
			distAField.setText("");
			distBField.setText("");
			distFx1Field.setText("");
			distFy1Field.setText("");
			distFz1Field.setText("");
			distMx1Field.setText("");
			distFx2Field.setText("");
			distFy2Field.setText("");
			distFz2Field.setText("");
			distMx2Field.setText("");
			distModButton.setEnabled(false);
			
			//Setting temperature fields
			TsField = new DecimalField(0, 7, numberFormat);
			TnField = new DecimalField(0, 7, numberFormat);
			TiField = new DecimalField(0, 7, numberFormat);
			TsField.setEnabled(false);
			TnField.setEnabled(false);
			TiField.setEnabled(false);
			
			//Setting initial equivalent forces fields
			eqFx1Field = new DecimalField(0, 7, numberFormat);
			eqFy1Field = new DecimalField(0, 7, numberFormat);
			eqFz1Field = new DecimalField(0, 7, numberFormat);
			eqMx1Field = new DecimalField(0, 7, numberFormat);
			eqMy1Field = new DecimalField(0, 7, numberFormat);
			eqMz1Field = new DecimalField(0, 7, numberFormat);
			eqFx2Field = new DecimalField(0, 7, numberFormat);
			eqFy2Field = new DecimalField(0, 7, numberFormat);
			eqFz2Field = new DecimalField(0, 7, numberFormat);
			eqMx2Field = new DecimalField(0, 7, numberFormat);
			eqMy2Field = new DecimalField(0, 7, numberFormat);
			eqMz2Field = new DecimalField(0, 7, numberFormat);
			
			//Setting pre-strains fields
			psDx1Field = new DecimalField(0, 7, numberFormat);
			psDy1Field = new DecimalField(0, 7, numberFormat);
			psDz1Field = new DecimalField(0, 7, numberFormat);
			psRx1Field = new DecimalField(0, 7, numberFormat);
			psRy1Field = new DecimalField(0, 7, numberFormat);
			psRz1Field = new DecimalField(0, 7, numberFormat);
			psDx2Field = new DecimalField(0, 7, numberFormat);
			psDy2Field = new DecimalField(0, 7, numberFormat);
			psDz2Field = new DecimalField(0, 7, numberFormat);
			psRx2Field = new DecimalField(0, 7, numberFormat);
			psRy2Field = new DecimalField(0, 7, numberFormat);
			psRz2Field = new DecimalField(0, 7, numberFormat);
			
		}
		
		//Enabling or disabling fields according to analysis model type
		if (this.parent.getController().getSelection().size() == 1)
			anlType = ((FrameElement)this.parent.getController().getSelection().get(0)).getAnalysisModel().getType();
		else anlType = fmodel.getGlobalAnalysisModel().getType();
		
		if (anlType.equals("Beam")) {
			
			concFxField.setEnabled(false);
			concFyField.setEnabled(true);
			concFzField.setEnabled(false);
			concMxField.setEnabled(false);
			concMyField.setEnabled(false);
			concMzField.setEnabled(true);
			
			distFx1Field.setEnabled(false);
			distFy1Field.setEnabled(true);
			distFz1Field.setEnabled(false);
			distMx1Field.setEnabled(false);
			distFx2Field.setEnabled(false);
			distFy2Field.setEnabled(true);
			distFz2Field.setEnabled(false);
			distMx2Field.setEnabled(false);
			
			liberationLdx1.setEnabled(false);
			liberationLdx2.setEnabled(false);
			liberationLdy1.setEnabled(true);
			liberationLdy2.setEnabled(true);
			liberationLdz1.setEnabled(false);
			liberationLdz2.setEnabled(false);
			liberationLrx1.setEnabled(false);
			liberationLrx2.setEnabled(false);
			liberationLry1.setEnabled(false);
			liberationLry2.setEnabled(false);
			liberationLrz1.setEnabled(true);
			liberationLrz2.setEnabled(true);
			
			psDx1Field.setEnabled(false);
			psDx2Field.setEnabled(false);
			psDy1Field.setEnabled(true);
			psDy2Field.setEnabled(true);
			psDz1Field.setEnabled(false);
			psDz2Field.setEnabled(false);
			psRx1Field.setEnabled(false);
			psRx2Field.setEnabled(false);
			psRy1Field.setEnabled(false);
			psRy2Field.setEnabled(false);
			psRz1Field.setEnabled(true);
			psRz2Field.setEnabled(true);
			
			eqFx1Field.setEnabled(false);
			eqFx2Field.setEnabled(false);
			eqFy1Field.setEnabled(true);
			eqFy2Field.setEnabled(true);
			eqFz1Field.setEnabled(false);
			eqFz2Field.setEnabled(false);
			eqMx1Field.setEnabled(false);
			eqMx2Field.setEnabled(false);
			eqMy1Field.setEnabled(false);
			eqMy2Field.setEnabled(false);
			eqMz1Field.setEnabled(true);
			eqMz2Field.setEnabled(true);
			
		} else if (anlType.equals("PlaneFrame")) {
			
			concFxField.setEnabled(true);
			concFyField.setEnabled(true);
			concFzField.setEnabled(false);
			concMxField.setEnabled(false);
			concMyField.setEnabled(false);
			concMzField.setEnabled(true);
			
			distFx1Field.setEnabled(true);
			distFy1Field.setEnabled(true);
			distFz1Field.setEnabled(false);
			distMx1Field.setEnabled(false);
			distFx2Field.setEnabled(true);
			distFy2Field.setEnabled(true);
			distFz2Field.setEnabled(false);
			distMx2Field.setEnabled(false);
			
			liberationLdx1.setEnabled(true);
			liberationLdx2.setEnabled(true);
			liberationLdy1.setEnabled(true);
			liberationLdy2.setEnabled(true);
			liberationLdz1.setEnabled(false);
			liberationLdz2.setEnabled(false);
			liberationLrx1.setEnabled(false);
			liberationLrx2.setEnabled(false);
			liberationLry1.setEnabled(false);
			liberationLry2.setEnabled(false);
			liberationLrz1.setEnabled(true);
			liberationLrz2.setEnabled(true);
			
			psDx1Field.setEnabled(true);
			psDx2Field.setEnabled(true);
			psDy1Field.setEnabled(true);
			psDy2Field.setEnabled(true);
			psDz1Field.setEnabled(false);
			psDz2Field.setEnabled(false);
			psRx1Field.setEnabled(false);
			psRx2Field.setEnabled(false);
			psRy1Field.setEnabled(false);
			psRy2Field.setEnabled(false);
			psRz1Field.setEnabled(true);
			psRz2Field.setEnabled(true);
			
			eqFx1Field.setEnabled(true);
			eqFx2Field.setEnabled(true);
			eqFy1Field.setEnabled(true);
			eqFy2Field.setEnabled(true);
			eqFz1Field.setEnabled(false);
			eqFz2Field.setEnabled(false);
			eqMx1Field.setEnabled(false);
			eqMx2Field.setEnabled(false);
			eqMy1Field.setEnabled(false);
			eqMy2Field.setEnabled(false);
			eqMz1Field.setEnabled(true);
			eqMz2Field.setEnabled(true);
			
		} else if (anlType.equals("PlaneTruss")) {
			
			concFxField.setEnabled(true);
			concFyField.setEnabled(true);
			concFzField.setEnabled(false);
			concMxField.setEnabled(false);
			concMyField.setEnabled(false);
			concMzField.setEnabled(false);
			
			distFx1Field.setEnabled(true);
			distFy1Field.setEnabled(true);
			distFz1Field.setEnabled(false);
			distMx1Field.setEnabled(false);
			distFx2Field.setEnabled(true);
			distFy2Field.setEnabled(true);
			distFz2Field.setEnabled(false);
			distMx2Field.setEnabled(false);
			
			liberationLdx1.setEnabled(true);
			liberationLdx2.setEnabled(true);
			liberationLdy1.setEnabled(true);
			liberationLdy2.setEnabled(true);
			liberationLdz1.setEnabled(false);
			liberationLdz2.setEnabled(false);
			liberationLrx1.setEnabled(false);
			liberationLrx2.setEnabled(false);
			liberationLry1.setEnabled(false);
			liberationLry2.setEnabled(false);
			liberationLrz1.setEnabled(false);
			liberationLrz2.setEnabled(false);
			
			psDx1Field.setEnabled(true);
			psDx2Field.setEnabled(true);
			psDy1Field.setEnabled(true);
			psDy2Field.setEnabled(true);
			psDz1Field.setEnabled(false);
			psDz2Field.setEnabled(false);
			psRx1Field.setEnabled(false);
			psRx2Field.setEnabled(false);
			psRy1Field.setEnabled(false);
			psRy2Field.setEnabled(false);
			psRz1Field.setEnabled(false);
			psRz2Field.setEnabled(false);
			
			eqFx1Field.setEnabled(true);
			eqFx2Field.setEnabled(true);
			eqFy1Field.setEnabled(true);
			eqFy2Field.setEnabled(true);
			eqFz1Field.setEnabled(false);
			eqFz2Field.setEnabled(false);
			eqMx1Field.setEnabled(false);
			eqMx2Field.setEnabled(false);
			eqMy1Field.setEnabled(false);
			eqMy2Field.setEnabled(false);
			eqMz1Field.setEnabled(false);
			eqMz2Field.setEnabled(false);
			
		} else if (anlType.equals("PlaneTruss")) {
			
			concFxField.setEnabled(false);
			concFyField.setEnabled(true);
			concFzField.setEnabled(false);
			concMxField.setEnabled(true);
			concMyField.setEnabled(false);
			concMzField.setEnabled(true);
			
			distFx1Field.setEnabled(false);
			distFy1Field.setEnabled(true);
			distFz1Field.setEnabled(false);
			distMx1Field.setEnabled(true);
			distFx2Field.setEnabled(false);
			distFy2Field.setEnabled(true);
			distFz2Field.setEnabled(false);
			distMx2Field.setEnabled(true);
			
			liberationLdx1.setEnabled(false);
			liberationLdx2.setEnabled(false);
			liberationLdy1.setEnabled(true);
			liberationLdy2.setEnabled(true);
			liberationLdz1.setEnabled(false);
			liberationLdz2.setEnabled(false);
			liberationLrx1.setEnabled(true);
			liberationLrx2.setEnabled(true);
			liberationLry1.setEnabled(false);
			liberationLry2.setEnabled(false);
			liberationLrz1.setEnabled(true);
			liberationLrz2.setEnabled(true);
			
			psDx1Field.setEnabled(false);
			psDx2Field.setEnabled(false);
			psDy1Field.setEnabled(true);
			psDy2Field.setEnabled(true);
			psDz1Field.setEnabled(false);
			psDz2Field.setEnabled(false);
			psRx1Field.setEnabled(true);
			psRx2Field.setEnabled(true);
			psRy1Field.setEnabled(false);
			psRy2Field.setEnabled(false);
			psRz1Field.setEnabled(true);
			psRz2Field.setEnabled(true);
			
			eqFx1Field.setEnabled(false);
			eqFx2Field.setEnabled(false);
			eqFy1Field.setEnabled(true);
			eqFy2Field.setEnabled(true);
			eqFz1Field.setEnabled(false);
			eqFz2Field.setEnabled(false);
			eqMx1Field.setEnabled(true);
			eqMx2Field.setEnabled(true);
			eqMy1Field.setEnabled(false);
			eqMy2Field.setEnabled(false);
			eqMz1Field.setEnabled(true);
			eqMz2Field.setEnabled(true);
			
		}
		
	}
	
//*****************************************************************************
	
	public void setUpMaterialsList() {
		
		int num = fmodel.getNumberOfMaterials();
		
		if (num > 0) {
			matLabelList = new String[num+1];
			matLabelList[0] = "----- " + parent.getResourceBundle().getString("dMatDialog03") + " -----";
			for (int i=0; i<num; i++)
				matLabelList[i+1] = ((Material)parent.getModel().getDiscreteModel().getMaterialsList().get(i)).getLabel();
		}else {
			matLabelList = new String[1];
			matLabelList[0] = "----- " + parent.getResourceBundle().getString("dMatDialog04") + " -----";
		}
		
	}
	
//*****************************************************************************
	
	public void setUpMaterialsCombo() {
		
		matListCombo.removeAllItems();
		for (int i=0; i<matLabelList.length; i++)
			matListCombo.addItem(matLabelList[i]);
		
	}
	
//*****************************************************************************
	
	public void setUpSectionsList() {
		
		int num = fmodel.getNumberOfSections();
		
		if (num > 0) {
			secLabelList = new String[num+1];
			secLabelList[0] = "--- " + parent.getResourceBundle().getString("dCSDialog05") + " ---";
			for (int i=0; i<num; i++)
				secLabelList[i+1] = ((CrossSection)(parent.getModel().getDiscreteModel()).getSectionsList().get(i)).getLabel();
		}else {
			secLabelList = new String[1];
			secLabelList[0] = "----- " + parent.getResourceBundle().getString("dCSDialog06") + " -----";
		}
		
	}
	
//*****************************************************************************
	
	public void setUpSectionsCombo() {
		
		secListCombo.removeAllItems();
		for (int i=0; i<secLabelList.length; i++)
			secListCombo.addItem(secLabelList[i]);
		
	}
	
//*****************************************************************************
	
	public void setUpConcList() {
		
		int num = concForces.size();
		
		if (num > 0) {
			concLabelList = new String[num];
			for (int i=0; i<num; i++)
				concLabelList[i] = (parent.getResourceBundle().getString("dEConcForDialog05") + " " + (i+1));
		} else {
			concLabelList = new String[1];
			concLabelList[0] = "----- " + parent.getResourceBundle().getString("dEConcForDialog06") + " -----";
		}
		
	}
	
//*****************************************************************************
	
	public void setUpConcCombo() {
		
		concListCombo.removeAllItems();
		for (int i=0; i<concLabelList.length; i++)
			concListCombo.addItem(concLabelList[i]);
		
	}
	
//*****************************************************************************
	
	public void setUpDistList() {
		
		int num = distForces.size();
		
		if (num > 0) {
			distLabelList = new String[num];
			for (int i=0; i<num; i++)
				distLabelList[i] = (parent.getResourceBundle().getString("dElmDistForDialog05") + " " + (i+1));
		} else {
			distLabelList = new String[1];
			distLabelList[0] = "----- " + parent.getResourceBundle().getString("dElmDistForDialog06") + " -----";
		}
		
	}
	
//*****************************************************************************
	
	public void setUpDistCombo() {
		
		distListCombo.removeAllItems();
		for (int i=0; i<distLabelList.length; i++)
			distListCombo.addItem(distLabelList[i]);
		
	}
	
//*****************************************************************************
	
	/** Private inner class to handle button events. */
	private class AnlComboListener implements ItemListener {
		public void itemStateChanged(ItemEvent evt) {
			
			int index = analysisTypeCombo.getSelectedIndex();
			
			if (index == 0) {
				
				concFxField.setEnabled(false);
				concFyField.setEnabled(true);
				concFzField.setEnabled(false);
				concMxField.setEnabled(false);
				concMyField.setEnabled(false);
				concMzField.setEnabled(true);
				
				distFx1Field.setEnabled(false);
				distFy1Field.setEnabled(true);
				distFz1Field.setEnabled(false);
				distMx1Field.setEnabled(false);
				distFx2Field.setEnabled(false);
				distFy2Field.setEnabled(true);
				distFz2Field.setEnabled(false);
				distMx2Field.setEnabled(false);
				
				if (secHField.getValue()!=0 && matThermalField.getValue()!=0) {
					TsField.setEnabled(true);
					TnField.setEnabled(false);
					TiField.setEnabled(true);
				}
				
				liberationLdx1.setEnabled(false);
				liberationLdx2.setEnabled(false);
				liberationLdy1.setEnabled(true);
				liberationLdy2.setEnabled(true);
				liberationLdz1.setEnabled(false);
				liberationLdz2.setEnabled(false);
				liberationLrx1.setEnabled(false);
				liberationLrx2.setEnabled(false);
				liberationLry1.setEnabled(false);
				liberationLry2.setEnabled(false);
				liberationLrz1.setEnabled(true);
				liberationLrz2.setEnabled(true);
				
				psDx1Field.setEnabled(false);
				psDx2Field.setEnabled(false);
				psDy1Field.setEnabled(true);
				psDy2Field.setEnabled(true);
				psDz1Field.setEnabled(false);
				psDz2Field.setEnabled(false);
				psRx1Field.setEnabled(false);
				psRx2Field.setEnabled(false);
				psRy1Field.setEnabled(false);
				psRy2Field.setEnabled(false);
				psRz1Field.setEnabled(true);
				psRz2Field.setEnabled(true);
				
				eqFx1Field.setEnabled(false);
				eqFx2Field.setEnabled(false);
				eqFy1Field.setEnabled(true);
				eqFy2Field.setEnabled(true);
				eqFz1Field.setEnabled(false);
				eqFz2Field.setEnabled(false);
				eqMx1Field.setEnabled(false);
				eqMx2Field.setEnabled(false);
				eqMy1Field.setEnabled(false);
				eqMy2Field.setEnabled(false);
				eqMz1Field.setEnabled(true);
				eqMz2Field.setEnabled(true);
				
			} else if (index == 1) {
				
				concFxField.setEnabled(true);
				concFyField.setEnabled(true);
				concFzField.setEnabled(false);
				concMxField.setEnabled(false);
				concMyField.setEnabled(false);
				concMzField.setEnabled(true);
				
				distFx1Field.setEnabled(true);
				distFy1Field.setEnabled(true);
				distFz1Field.setEnabled(false);
				distMx1Field.setEnabled(false);
				distFx2Field.setEnabled(true);
				distFy2Field.setEnabled(true);
				distFz2Field.setEnabled(false);
				distMx2Field.setEnabled(false);
				
				if (secHField.getValue()!=0 && matThermalField.getValue()!=0) {
					TsField.setEnabled(true);
					TnField.setEnabled(true);
					TiField.setEnabled(true);
				}
				
				liberationLdx1.setEnabled(true);
				liberationLdx2.setEnabled(true);
				liberationLdy1.setEnabled(true);
				liberationLdy2.setEnabled(true);
				liberationLdz1.setEnabled(false);
				liberationLdz2.setEnabled(false);
				liberationLrx1.setEnabled(false);
				liberationLrx2.setEnabled(false);
				liberationLry1.setEnabled(false);
				liberationLry2.setEnabled(false);
				liberationLrz1.setEnabled(true);
				liberationLrz2.setEnabled(true);
				
				psDx1Field.setEnabled(true);
				psDx2Field.setEnabled(true);
				psDy1Field.setEnabled(true);
				psDy2Field.setEnabled(true);
				psDz1Field.setEnabled(false);
				psDz2Field.setEnabled(false);
				psRx1Field.setEnabled(false);
				psRx2Field.setEnabled(false);
				psRy1Field.setEnabled(false);
				psRy2Field.setEnabled(false);
				psRz1Field.setEnabled(true);
				psRz2Field.setEnabled(true);
				
				eqFx1Field.setEnabled(true);
				eqFx2Field.setEnabled(true);
				eqFy1Field.setEnabled(true);
				eqFy2Field.setEnabled(true);
				eqFz1Field.setEnabled(false);
				eqFz2Field.setEnabled(false);
				eqMx1Field.setEnabled(false);
				eqMx2Field.setEnabled(false);
				eqMy1Field.setEnabled(false);
				eqMy2Field.setEnabled(false);
				eqMz1Field.setEnabled(true);
				eqMz2Field.setEnabled(true);
				
			} else if (index == 2) {
				
				concFxField.setEnabled(true);
				concFyField.setEnabled(true);
				concFzField.setEnabled(false);
				concMxField.setEnabled(false);
				concMyField.setEnabled(false);
				concMzField.setEnabled(false);
				
				distFx1Field.setEnabled(true);
				distFy1Field.setEnabled(true);
				distFz1Field.setEnabled(false);
				distMx1Field.setEnabled(false);
				distFx2Field.setEnabled(true);
				distFy2Field.setEnabled(true);
				distFz2Field.setEnabled(false);
				distMx2Field.setEnabled(false);
				
				if (secHField.getValue()!=0 && matThermalField.getValue()!=0) {
					TsField.setEnabled(false);
					TnField.setEnabled(true);
					TiField.setEnabled(false);
				}
				
				liberationLdx1.setEnabled(true);
				liberationLdx2.setEnabled(true);
				liberationLdy1.setEnabled(true);
				liberationLdy2.setEnabled(true);
				liberationLdz1.setEnabled(false);
				liberationLdz2.setEnabled(false);
				liberationLrx1.setEnabled(false);
				liberationLrx2.setEnabled(false);
				liberationLry1.setEnabled(false);
				liberationLry2.setEnabled(false);
				liberationLrz1.setEnabled(false);
				liberationLrz2.setEnabled(false);
				
				psDx1Field.setEnabled(true);
				psDx2Field.setEnabled(true);
				psDy1Field.setEnabled(true);
				psDy2Field.setEnabled(true);
				psDz1Field.setEnabled(false);
				psDz2Field.setEnabled(false);
				psRx1Field.setEnabled(false);
				psRx2Field.setEnabled(false);
				psRy1Field.setEnabled(false);
				psRy2Field.setEnabled(false);
				psRz1Field.setEnabled(false);
				psRz2Field.setEnabled(false);
				
				eqFx1Field.setEnabled(true);
				eqFx2Field.setEnabled(true);
				eqFy1Field.setEnabled(true);
				eqFy2Field.setEnabled(true);
				eqFz1Field.setEnabled(false);
				eqFz2Field.setEnabled(false);
				eqMx1Field.setEnabled(false);
				eqMx2Field.setEnabled(false);
				eqMy1Field.setEnabled(false);
				eqMy2Field.setEnabled(false);
				eqMz1Field.setEnabled(false);
				eqMz2Field.setEnabled(false);
				
			}
			
		}
	}
	
//*****************************************************************************
	
	/** Private inner class to handle button events. */
	private class MatComboListener implements ItemListener {
		public void itemStateChanged(ItemEvent evt) {
			
			int index = matListCombo.getSelectedIndex();
			
			if (index > 0 ) {
				
			    LinearElasticIsotropic material = (LinearElasticIsotropic)fmodel.getMaterialsList().get(index-1);
				
				matEField.setValue(material.getMaterialValues(material.ELASTICITY).doubleValue());
				matGField.setValue(material.getMaterialValues(material.SHEAR_MODULUS).doubleValue());
				matPoissonField.setValue(material.getMaterialValues(material.POISSON).doubleValue());
				matThermalField.setValue(material.getMaterialValues(material.THERMAL_COEFF).doubleValue());
			
			} else {
				
				matEField.setText(" ");
				matGField.setText(" ");
				matPoissonField.setText(" ");
				matThermalField.setText(" ");
				
			}
			
		}
	}
	
//*****************************************************************************
	
	/** Private inner class to handle button events. */
	private class MatGListener implements FocusListener {
		
		public void focusGained(FocusEvent evt) {}
		
		public void focusLost(FocusEvent evt) {
			double g = matGField.getValue();
			double e = matEField.getValue();
			double p = e / (2*g) - 1;
			if ( g!=0 && e!=0 && (p<0 || p>0.5)) {
				JOptionPane.showMessageDialog(parent,
					parent.getResourceBundle().getString("dMatDialog10") + " (\u03BD = " + numberFormat2.format(p) + ")",
					parent.getResourceBundle().getString("cmError"), JOptionPane.ERROR_MESSAGE);
				matGField.setValue(0);
				matGField.setText(parent.getResourceBundle().getString("gmInvalidData"));
			}
			if (p>=0 && p<=0.5 && e!=0) {
				matPoissonField.setValue(p);
				matPoissonField.setText(numberFormat2.format(p));
			}
		}
		
	}
	
//*****************************************************************************
	
	/** Private inner class to handle button events. */
	private class MatPoissonListener implements FocusListener {
		
		public void focusGained(FocusEvent evt) {}
		
		public void focusLost(FocusEvent evt) {
			double p = matPoissonField.getValue();
			if (p<0 || p>0.5) {
				JOptionPane.showMessageDialog(parent,
					parent.getResourceBundle().getString("dMatDialog11") + "\n                          0.0 \u2264 \u03BD \u2264 0.5",
					parent.getResourceBundle().getString("cmError"), JOptionPane.ERROR_MESSAGE);
					matPoissonField.setValue(0);
					matPoissonField.setText(parent.getResourceBundle().getString("gmInvalidData"));
			} else {
				double e = matEField.getValue();
				if (e!=0) {
					double g = e / (2*(1+p));
					if (p>=0 && p<=0.5) {
						matGField.setValue(g);
						matGField.setText(numberFormat2.format(g));
					}
				}
			}
		}
		
	}
	
//*****************************************************************************
	
	/** Private inner class to handle button events. */
	private class SecComboListener implements ItemListener {
		public void itemStateChanged(ItemEvent evt) {
			
			int index = secListCombo.getSelectedIndex();
			
			if (index > 0 ) {
				
				CrossSection section = (CrossSection)fmodel.getSectionsList().get(index-1);
				
				secIxField.setValue(section.getIx());
				secIyField.setValue(section.getIy());
				secIzField.setValue(section.getIz());
				secAField.setValue(section.getArea());
				secHField.setValue(section.getHeight());
				secThickField.setValue(section.getThickness());
				
			} else {
				
				secIxField.setText(" ");
				secIyField.setText(" ");
				secIzField.setText(" ");
				secAField.setText(" ");
				secHField.setText(" ");
				secThickField.setText(" ");
				
			}
			
		}
	}
	
//*****************************************************************************
	
	/** Private inner class to handle button events. */
	private class TempListener implements FocusListener {
		
		public void focusGained(FocusEvent evt) {}
		
		public void focusLost(FocusEvent evt) {
			
			double t = 0;
			double h = 0;
			
			if (matListCombo.getSelectedIndex()!=0)
				t = matThermalField.getValue();
			if (secListCombo.getSelectedIndex()!=0)
				t = secHField.getValue();
			
			int index = analysisTypeCombo.getSelectedIndex();
			String str = analysisTypeStr[index];
			
			if (h!=0 && t!=0) {
				if (str.equals("Beam")) {
					TsField.setEnabled(true);
					TnField.setEnabled(false);
					TiField.setEnabled(true);
				} else if (str.equals("Plane Frame")) {
					TsField.setEnabled(true);
					TnField.setEnabled(true);
					TiField.setEnabled(true);
				} else if (str.equals("Plane Truss")) {
					TsField.setEnabled(false);
					TnField.setEnabled(true);
					TiField.setEnabled(false);
				}
			} else {
				TsField.setEnabled(false);
				TnField.setEnabled(false);
				TiField.setEnabled(false);
			
			}
		}
	}
	
//*****************************************************************************
	
	/** Private inner class to handle button events. */
	private class ConcComboListener implements ItemListener {
		public void itemStateChanged(ItemEvent evt) {
			
			int index = concListCombo.getSelectedIndex();
			int listSize = concForces.size();
			
			if (listSize>0 && index>=0) {
				
				PointForce force = (PointForce)concForces.get(index);
				
				concAField.setValue(force.getCoord().x);
				concFxField.setValue(force.getForce(0));
				concFyField.setValue(force.getForce(1));
				concFzField.setValue(force.getForce(2));
				concMxField.setValue(force.getForce(3));
				concMyField.setValue(force.getForce(4));
				concMzField.setValue(force.getForce(5));
				
				concModButton.setEnabled(true);
			
			} else {
				
				concAField.setText(" ");
				concFxField.setText(" ");
				concFyField.setText(" ");
				concFzField.setText(" ");
				concMxField.setText(" ");
				concMyField.setText(" ");
				concMzField.setText(" ");
				
				concModButton.setEnabled(false);
				
			}
			
		}
	}
	
//*****************************************************************************
	
	/** Private inner class to handle button events. */
	private class ConcNewListener implements ActionListener {
		public void actionPerformed(ActionEvent evt) {
			
			concCardManager.show(concButPane, "concLabel");
			setButtonsEnabled(false);
			
			concAField.setEditable(true);
			concFxField.setEditable(true);
			concFyField.setEditable(true);
			concFzField.setEditable(true);
			concMxField.setEditable(true);
			concMyField.setEditable(true);
			concMzField.setEditable(true);
			
			int index = concForces.size()+1;
			
			concLabelField.setText(parent.getResourceBundle().getString("dEConcForDialog05") + " " + index);
			concAField.setValue(0);
			concFxField.setValue(0);
			concFyField.setValue(0);
			concFzField.setValue(0);
			concMxField.setValue(0);
			concMyField.setValue(0);
			concMzField.setValue(0);
			
			concNewPressed = true;
			
		}
	}
	
//*****************************************************************************
	
	/** Private inner class to handle button events. */
	private class ConcModListener implements ActionListener {
		public void actionPerformed(ActionEvent evt) {
			
			concCardManager.show(concButPane, "concLabel");
			setButtonsEnabled(false);
			
			concNewPressed = false;
			
			int index = concListCombo.getSelectedIndex();
			
			concLabelField.setText(parent.getResourceBundle().getString("dEConcForDialog05") + " " + (index+1));
			
			concAField.setEditable(true);
			concFxField.setEditable(true);
			concFyField.setEditable(true);
			concFzField.setEditable(true);
			concMxField.setEditable(true);
			concMyField.setEditable(true);
			concMzField.setEditable(true);
			
			if (anlType.equals("Beam")) {
				concFxField.setEnabled(false);
				concFyField.setEnabled(true);
				concFzField.setEnabled(false);
				concMxField.setEnabled(false);
				concMyField.setEnabled(false);
				concMzField.setEnabled(true);
			} else if (anlType.equals("PlaneFrame")) {
				concFxField.setEnabled(true);
				concFyField.setEnabled(true);
				concFzField.setEnabled(false);
				concMxField.setEnabled(false);
				concMyField.setEnabled(false);
				concMzField.setEnabled(true);
			} else if (anlType.equals("PlaneTruss")) {
				concFxField.setEnabled(true);
				concFyField.setEnabled(true);
				concFzField.setEnabled(false);
				concMxField.setEnabled(false);
				concMyField.setEnabled(false);
				concMzField.setEnabled(false);
			}
			
		}
	}
	
//*****************************************************************************
	
	/** Private inner class to handle button events. */
	private class ConcOkListener implements ActionListener {
		public void actionPerformed(ActionEvent evt) {
			
			boolean dataOk = true;
			int currentIndex = concListCombo.getSelectedIndex();
			
			//Checking if the distance a is higher than the length of the element
			//It must be less than the length.
			if (parent.getController().getSelection().size() == 1 ) {
				FrameElement elm = (FrameElement)parent.getController().getSelection().get(0);
				double l = elm.getLength();
				double a = concAField.getValue();
				if (a>l){
					JOptionPane.showMessageDialog(parent,
						parent.getResourceBundle().getString("dEConcForDialog07"),
						parent.getResourceBundle().getString("cmError"), JOptionPane.ERROR_MESSAGE);
					concAField.setValue(l);
					dataOk = false;
				}
			}
			
			if (dataOk) {
				
				concCardManager.show(concButPane, "concCombo");
				setButtonsEnabled(true);
				
				concAField.setEditable(false);
				concFxField.setEditable(false);
				concFyField.setEditable(false);
				concFzField.setEditable(false);
				concMxField.setEditable(false);
				concMyField.setEditable(false);
				concMzField.setEditable(false);
				
				double a = concAField.getValue();
				double fx = concFxField.getValue();
				double fy = concFyField.getValue();
				double fz = concFzField.getValue();
				double mx = concMxField.getValue();
				double my = concMyField.getValue();
				double mz = concMzField.getValue();
				
				PointForce force = new PointForce();
				
				if (concNewPressed) {
					
					force.setForce(0, fx);
					force.setForce(1, fy);
					force.setForce(2, fz);
					force.setForce(3, mx);
					force.setForce(4, my);
					force.setForce(5, mz);
					force.setCoord(a, 0, 0);
					
					concForces.add(force);
					
					setUpConcList();
					setUpConcCombo();
					concListCombo.setSelectedIndex(concForces.size()-1);
					
					concNewPressed = false;
					
				} else {
					
					force = (PointForce)concForces.get(currentIndex);
					force.setForce(0, fx);
					force.setForce(1, fy);
					force.setForce(2, fz);
					force.setForce(3, mx);
					force.setForce(4, my);
					force.setForce(5, mz);
					force.setCoord(a, 0, 0);
					
					concListCombo.setSelectedIndex(currentIndex);
				}
				
			}
		}
	}
	
//*****************************************************************************
	
	/** Private inner class to handle button events. */
	private class ConcCancListener implements ActionListener {
		public void actionPerformed(ActionEvent evt) {
			
			concCardManager.show(concButPane, "concCombo");
			setButtonsEnabled(true);
			
			concAField.setEditable(false);
			concFxField.setEditable(false);
			concFyField.setEditable(false);
			concFzField.setEditable(false);
			concMxField.setEditable(false);
			concMyField.setEditable(false);
			concMzField.setEditable(false);
			
			int listSize = concForces.size();
			int index = concListCombo.getSelectedIndex();
			
			if (listSize==0) {
				
				concAField.setText("");
				concFxField.setText("");
				concFyField.setText("");
				concFzField.setText("");
				concMxField.setText("");
				concMyField.setText("");
				concMzField.setText("");
				
			} else {
				PointForce force = (PointForce)concForces.get(index);
				
				concAField.setValue(force.getCoord().x);
				concFxField.setValue(force.getForce(0));
				concFyField.setValue(force.getForce(1));
				concFzField.setValue(force.getForce(2));
				concMxField.setValue(force.getForce(3));
				concMyField.setValue(force.getForce(4));
				concMzField.setValue(force.getForce(5));
				
			}
			
			concNewPressed = false;
			
		}
	}
	
//*****************************************************************************

/** Private inner class to handle button events. */
	private class DistComboListener implements ItemListener {
		public void itemStateChanged(ItemEvent evt) {
			
			int index = distListCombo.getSelectedIndex();
			int listSize = distForces.size();
			
			if (listSize>0 && index>=0) {
				
				ElementForce dforce = (ElementForce)distForces.get(index);
				PointForce iforce = (PointForce)dforce.getPointForcesList().get(0);
				PointForce fforce = (PointForce)dforce.getPointForcesList().get(1);
				
				distAField.setValue(iforce.getCoord().x);
				distBField.setValue(fforce.getCoord().x);
				distFx1Field.setValue(iforce.getForce(0));
				distFy1Field.setValue(iforce.getForce(1));
				distFz1Field.setValue(iforce.getForce(2));
				distMx1Field.setValue(iforce.getForce(3));
				distFx2Field.setValue(fforce.getForce(0));
				distFy2Field.setValue(fforce.getForce(1));
				distFz2Field.setValue(fforce.getForce(2));
				distMx2Field.setValue(fforce.getForce(3));
				
				distModButton.setEnabled(true);
			
			} else {
				
				distAField.setText(" ");
				distBField.setText(" ");
				distFx1Field.setText(" ");
				distFy1Field.setText(" ");
				distFz1Field.setText(" ");
				distMx1Field.setText(" ");
				distFx2Field.setText(" ");
				distFy2Field.setText(" ");
				distFz2Field.setText(" ");
				distMx2Field.setText(" ");
				
				distModButton.setEnabled(false);
				
			}
			
		}
	}
	
//*****************************************************************************
	
	/** Private inner class to handle button events. */
	private class DistNewListener implements ActionListener {
		public void actionPerformed(ActionEvent evt) {
			
			distCardManager.show(distButPane, "distLabel");
			setButtonsEnabled(false);
			
			distAField.setEditable(true);
			distBField.setEditable(true);
			distFx1Field.setEditable(true);
			distFy1Field.setEditable(true);
			distFz1Field.setEditable(true);
			distMx1Field.setEditable(true);
			distFx2Field.setEditable(true);
			distFy2Field.setEditable(true);
			distFz2Field.setEditable(true);
			distMx2Field.setEditable(true);
			
			int index = distForces.size()+1;
			
			distLabelField.setText(parent.getResourceBundle().getString("dElmDistForDialog05") + " " + index);
			
			distAField.setValue(0);
			
			if (parent.getController().getSelection().size() == 1 ) {
				FrameElement elm = (FrameElement)parent.getController().getSelection().get(0);
				distBField.setValue(elm.getLength());
				distBField.setText(numberFormat2.format(elm.getLength()));
			} else {
				distBField.setValue(0);
			}
			
			distFx1Field.setValue(0);
			distFy1Field.setValue(0);
			distFz1Field.setValue(0);
			distMx1Field.setValue(0);
			distFx2Field.setValue(0);
			distFy2Field.setValue(0);
			distFz2Field.setValue(0);
			distMx2Field.setValue(0);
			
			distNewPressed = true;
			
		}
	}
	
//*****************************************************************************
	
	/** Private inner class to handle button events. */
	private class DistModListener implements ActionListener {
		public void actionPerformed(ActionEvent evt) {
			
			distCardManager.show(distButPane, "distLabel");
			setButtonsEnabled(false);
			
			distNewPressed = false;
			
			int index = distListCombo.getSelectedIndex();
			
			distLabelField.setText(parent.getResourceBundle().getString("dElmDistForDialog05") + " " + (index+1));
			
			distAField.setEditable(true);
			distBField.setEditable(true);
			distFx1Field.setEditable(true);
			distFy1Field.setEditable(true);
			distFz1Field.setEditable(true);
			distMx1Field.setEditable(true);
			distFx2Field.setEditable(true);
			distFy2Field.setEditable(true);
			distFz2Field.setEditable(true);
			distMx2Field.setEditable(true);
			
			if (anlType.equals("Beam")) {
				distFx1Field.setEnabled(false);
				distFy1Field.setEnabled(true);
				distFz1Field.setEnabled(false);
				distMx1Field.setEnabled(false);
				distFx2Field.setEnabled(false);
				distFy2Field.setEnabled(true);
				distFz2Field.setEnabled(false);
				distMx2Field.setEnabled(false);
				
			} else if (anlType.equals("PlaneFrame")) {
				
				distFx1Field.setEnabled(true);
				distFy1Field.setEnabled(true);
				distFz1Field.setEnabled(false);
				distMx1Field.setEnabled(false);
				distFx2Field.setEnabled(true);
				distFy2Field.setEnabled(true);
				distFz2Field.setEnabled(false);
				distMx2Field.setEnabled(false);
				
			} else if (anlType.equals("PlaneTruss")) {
				
				distFx1Field.setEnabled(true);
				distFy1Field.setEnabled(true);
				distFz1Field.setEnabled(false);
				distMx1Field.setEnabled(false);
				distFx2Field.setEnabled(true);
				distFy2Field.setEnabled(true);
				distFz2Field.setEnabled(false);
				distMx2Field.setEnabled(false);
				
			}
			
		}
	}
	
//*****************************************************************************
	
	/** Private inner class to handle button events. */
	private class DistOkListener implements ActionListener {
		public void actionPerformed(ActionEvent evt) {
			
			boolean dataOk = true;
			int currentIndex = distListCombo.getSelectedIndex();
			
			//Checking if the distances a and b are higher than the length of the element
			//It must be less than the length.
			if (parent.getController().getSelection().size() == 1 ) {
				FrameElement elm = (FrameElement)parent.getController().getSelection().get(0);
				double l = elm.getLength();
				double a = distAField.getValue();
				double b = distBField.getValue();
				if (a>l || b>l){
					JOptionPane.showMessageDialog(parent,
						parent.getResourceBundle().getString("dElmDistForDialog07"),
						parent.getResourceBundle().getString("cmError"), JOptionPane.ERROR_MESSAGE);
					distAField.setValue(0);
					distAField.setValue(l);
					distBField.setValue(l);
					dataOk = false;
				}
			}
			
			if (dataOk) {
				
				distCardManager.show(distButPane, "distCombo");
				setButtonsEnabled(true);
				
				distAField.setEditable(false);
				distBField.setEditable(false);
				distFx1Field.setEditable(false);
				distFy1Field.setEditable(false);
				distFz1Field.setEditable(false);
				distMx1Field.setEditable(false);
				distFx2Field.setEditable(false);
				distFy2Field.setEditable(false);
				distFz2Field.setEditable(false);
				distMx2Field.setEditable(false);
				
				double a = distAField.getValue();
				double b = distBField.getValue();
				double fx1 = distFx1Field.getValue();
				double fy1 = distFy1Field.getValue();
				double fz1 = distFz1Field.getValue();
				double mx1 = distMx1Field.getValue();
				double fx2 = distFx2Field.getValue();
				double fy2 = distFy2Field.getValue();
				double fz2 = distFz2Field.getValue();
				double mx2 = distMx2Field.getValue();
				
				ElementForce dforce = new ElementForce();
				PointForce iforce = new PointForce();
				PointForce fforce = new PointForce();
				
				if (distNewPressed) {
					
					iforce.setForce(0, fx1);
					iforce.setForce(1, fy1);
					iforce.setForce(2, fz1);
					iforce.setForce(3, mx1);
					iforce.setCoord(a, 0, 0);
					fforce.setForce(0, fx2);
					fforce.setForce(1, fy2);
					fforce.setForce(2, fz2);
					fforce.setForce(3, mx2);
					fforce.setCoord(b, 0, 0);
					
					dforce.getPointForcesList().add(0, iforce);
					dforce.getPointForcesList().add(1, fforce);
					
					distForces.add(dforce);
					
					setUpDistList();
					setUpDistCombo();
					distListCombo.setSelectedIndex(distForces.size()-1);
					
					distNewPressed = false;
					
				} else {
					
					dforce = (ElementForce)distForces.get(currentIndex);
					iforce = (PointForce)dforce.getPointForcesList().get(0);
					fforce = (PointForce)dforce.getPointForcesList().get(1);
					iforce.setForce(0, fx1);
					iforce.setForce(1, fy1);
					iforce.setForce(2, fz1);
					iforce.setForce(3, mx1);
					iforce.setCoord(a, 0, 0);
					fforce.setForce(0, fx2);
					fforce.setForce(1, fy2);
					fforce.setForce(2, fz2);
					fforce.setForce(3, mx2);
					fforce.setCoord(b, 0, 0);
					
					distListCombo.setSelectedIndex(currentIndex);
				}
				
			}
			
		}
	}
	
//*****************************************************************************
	
	/** Private inner class to handle button events. */
	private class DistCancListener implements ActionListener {
		public void actionPerformed(ActionEvent evt) {
			
			distCardManager.show(distButPane, "distCombo");
			setButtonsEnabled(true);
			
			distAField.setEditable(false);
			distBField.setEditable(false);
			distFx1Field.setEditable(false);
			distFy1Field.setEditable(false);
			distFz1Field.setEditable(false);
			distMx1Field.setEditable(false);
			distFx2Field.setEditable(false);
			distFy2Field.setEditable(false);
			distFz2Field.setEditable(false);
			distMx2Field.setEditable(false);
			
			int listSize = distForces.size();
			int index = distListCombo.getSelectedIndex();
			
			if (listSize==0) {
				
				distAField.setText("");
				distBField.setText("");
				distFx1Field.setText("");
				distFy1Field.setText("");
				distFz1Field.setText("");
				distMx1Field.setText("");
				distFx2Field.setText("");
				distFy2Field.setText("");
				distFz2Field.setText("");
				distMx2Field.setText("");
				
			} else {
				ElementForce dforce = (ElementForce)distForces.get(index);
				PointForce iforce = (PointForce)dforce.getPointForcesList().get(0);
				PointForce fforce = (PointForce)dforce.getPointForcesList().get(1);
				
				distAField.setValue(iforce.getCoord().x);
				distBField.setValue(fforce.getCoord().x);
				distFx1Field.setValue(iforce.getForce(0));
				distFy1Field.setValue(iforce.getForce(1));
				distFz1Field.setValue(iforce.getForce(2));
				distMx1Field.setValue(iforce.getForce(3));
				distFx2Field.setValue(fforce.getForce(0));
				distFy2Field.setValue(fforce.getForce(1));
				distFz2Field.setValue(fforce.getForce(2));
				distMx2Field.setValue(fforce.getForce(3));
				
			}
			
			distNewPressed = false;
			
		}
	}
	
//*****************************************************************************
}

